[R] why querying Sybase IQ using RODBC returns error ?
Hello, I am not able to query Sybase IQ database from R using RODBC package. Check the below code R sybaseiq.query - function (sql, ..., as.is = FALSE) { connstr - Driver={Sybase IQ};UID=ajadhav2;PWD=*;ServerName=PSGSESHR01A_IQ;CommLinks=SharedMemory,TCPIP{host=psgseshr01_iq.sg.csfb.com;port=3051} chan - odbcDriverConnect(connstr) on.exit(odbcClose(chan)) if (length(list(...)) 0) sql - sprintf(sql, ...) x - sqlQuery(chan, sql, as.is = as.is) return(x) } R R R R x - sybaseiq.query(select * from syagprd1.orders where tradedate='120727' and acct='DVW') Error in .Call(C_RODBCFetchRows, attr(channel, handle_ptr), max, buffsize, : negative length vectors are not allowed R x [1] 42000 -131 [Sybase][ODBC Driver][Sybase IQ]Syntax error near 'order' on line 1 [2] [RODBC] ERROR: Could not SQLExecDirect 'select * from syagprd1.order where tradedate='120727' and acct='DVW' and ptag=-1 and sym='BHP.AX'' This is same behavior for empty datasets also R x - agora.query.iq(select * from syagprd1.orders where 1=2) Error in .Call(C_RODBCFetchRows, attr(channel, handle_ptr), max, buffsize, : negative length vectors are not allowed I am not sure what is wrong. Are their some arguments I need to know while I create chan to resolve this issue? Thanks for your help in advance. Regards, Alok -- View this message in context: http://r.789695.n4.nabble.com/why-querying-Sybase-IQ-using-RODBC-returns-error-tp4638297.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Hints for the best package
Thanks a million, Michael. I really appreciated it. Marco -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Sunday, July 29, 2012 5:03 PM To: MP Cc: r-help@r-project.org Subject: Re: [R] Hints for the best package It sounds like you want multiple logistic regression: I think most people find the mlogit package quite helpful there. See also: http://www.ats.ucla.edu/stat/r/dae/mlogit.htm Michael On Sun, Jul 29, 2012 at 9:02 AM, MP ny2292...@yahoo.com wrote: I am new to this field and I am currently studying the most basic problem of statistics, I think. I have an indicator that is 0 or 1 and many categorical and continuous variables. I have to create a predictive model for the indicator. Could anyone provide me a direction in terms of packages that already tackled this kind of problem. Thanks, Marco __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Zoo panel function
I would really like some help with understanding the panel function, in zoo. Thank you. R 15.1 and zoo 1.7-7. library(zoo) x = seq(0,3*pi,length.out=100) y = sin(x) zobj = zoo(y, x) ### ## EXAMPLE 1 - GLOBAL ARGUMENT ## This panel function works ## But, it relies on mycol, which is a global variable ### palette(rainbow(100)) mypanel_v1 = function(x, y, ...){ lines(x, y, lty=2, col='grey') points(x, y, col=mycol, pch=16) } mycol = round((y - min(y)) / (max(y) - min(y)) * 99) + 1 plot(zobj, panel=mypanel_v1) ### ## EXAMPLE 2 - PASSING IN MY_COLOR AS PARAM (WITH WARNING) ## How would I make the color argument modular? ## This works, but throws errors ## What is the best way to to this? ### palette(rainbow(100)) mypanel_v2 = function(x, y, MY_COLOR, ...){ lines(x, y, lty=2, col='grey') points(x, y, col=MY_COLOR, pch=16) ## By the way I also tried a variety of strategies ## like this: # points(..., col=MY_COLOR, pch=16) ## but I get got warnings about passing in pch and col ## more than once, and matching multiple arguments. ## The col value has the length of number of zoo ## objects rather than the number of points in each ## column } mycol = round((y - min(y)) / (max(y) - min(y)) * 50) + 1 plot(zobj, panel=mypanel_v2, MY_COLOR = mycol) Thank you, Gene Leynes _ *Data Scientist* *http://www.linkedin.com/in/geneleynes * http://goog_598053156*http://geneorama.com/ http://geneorama.com/%20* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R- Help (looping)
Hi, I'm Wellington from Brazil and I have the following issue: I've been working on a project a for a while, and I'm having trouble in using the loop (for) I need to read a column (c1), and for each value of this column, I need to check if it's within the control limits So, I was trying to do this: For (k in 1: c1) If (c1 lcl1 | c1 ucl1) {here I need to store the values outside the limits) I have 5 columns, need to do the same process in each one of them. And later on I'm gonna concatenate these 5 vectors and calculate its mean for an ARL project. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] curve comparison
Dear R users, I have seven regression lines I´d like to compare, in order to find out if these are significatively different. The main problem is that these are curves, non normal, non homogeneous data, I´ve tried to linearize them but it has not worked. So I´d like to know if you know any command or source in R which explains how to perform this kind of comparison. Thanks in advance for your help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rJava loading error on hp-ux
Hi all, When I installed rJava from source, rJava installation was failed with below messges. $ R CMD INSTALL rJava_0.9-4.tar.gz ... ... ... gmake[1]: Leaving directory `/tmp/RtmpNwiCae/R.INSTALL4ebb76a3400d/rJava/jri' installing via 'install.libs.R' to /stat/R-2.15.1/lib/R/library/rJava ** R ** inst ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** testing if installed package can be loaded /usr/lib/hpux32/dld.so: Unable to find library 'libc.so'. Failed to open libc ERROR: loading failed * removing '/stat/R-2.15.1/lib/R/library/rJava' * restoring previous '/stat/R-2.15.1/lib/R/library/rJava' How can I solve this problem? Thank you in advance. --- Addtional information #1 gt; sessionInfo() R version 2.15.1 (2012-06-22) Platform: ia64-hp-hpux11.31 (32-bit) --- Addtional information #2 $ R CMD javareconf Java interpreter : /opt/java6/jre/bin/java Java version : 1.6.0.05 Java home path : /opt/java6 Java compiler: /opt/java6/bin/javac Java headers gen.: /opt/java6/bin/javah Java archive tool: /opt/java6/bin/jar Java library path: $(JAVA_HOME)/jre/lib/IA64N:$(JAVA_HOME)/jre/lib/IA64N/server:$(JAVA_HOME)/jre/../lib/IA64N::/usr/lib JNI linker flags : -L$(JAVA_HOME)/jre/lib/IA64N -L$(JAVA_HOME)/jre/lib/IA64N/server -L$(JAVA_HOME)/jre/../lib/IA64N -L -L/usr/lib -ljvm JNI cpp flags: -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/hp-ux Updating Java configuration in /stat/R-2.15.1/lib/R Done. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extended R
hony mn.nasiri at gmail.com writes: I need to create a software and use R engine in my software. but I don't know how to use R code in my software same www.revolutionanalytics.com. Rapid Miner has 2 section. one of them is using for application and the other is used for researcher for extended it. Unfortunately, this question isn't really comprehensible to someone who doesn't already know what you're talking about. Have you read the Introduction to R, and the posting guide for the help list? Have you searched the archives of this list for possible answers? You might also look on Stack Overflow under the [r] tag for answers -- lots of data mining/analytics types hang out there. good luck Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting results from the VAR output
Hi guys, Thank you very much :) It seems that both your suggestions works. I wasn't aware of the function [[argument]], it makes the programming procedure much easier! :) Best regards, Emil -- View this message in context: http://r.789695.n4.nabble.com/Extracting-results-from-the-VAR-output-tp4638072p4638300.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] distance matrix and hclustering
Dear R Users,i am very new to R. I want your help on an issue regarding distance matrix and cluster analysis i had discharge data of 4 rivers(a,b,c,d) in 4 vectors each having 364 values dput(qmu)structure(list(a = c(0.26, 0.25, 0.25, 0.25, 0.24, 0.23, 0.22, 0.21, 0.21, 0.21, 0.2, 0.19, 0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.18, 0.19, 0.19, 0.19, 0.2, 0.21, 0.21, 0.21, 0.21, 0.21, 0.21, 0.19, 0.19, 0.18, 0.17, 0.17, 0.15, 0.18, 0.2, 0.21, 0.2, 0.19, 0.19, 0.19, 0.2, 0.24, 0.3, 0.3, 0.3, 0.32, 0.34, 0.42, 0.46, 0.48, 0.67, 0.82, 0.79, 0.73, 0.69, 0.67, 0.67, 0.66, 0.64, 0.61, 0.58, 0.56, 0.55, 0.55, 0.55, 0.52, 0.49, 0.48, 0.51, 0.53, 0.52, 0.49, 0.48, 0.48, 0.46, 0.46, 0.44, 0.43, 0.43, 0.41, 0.48, 0.55, 0.57, 0.55, 0.56, 0.6, 0.64, 0.67, 0.73, 0.84, 0.94, 1.09, 1.24, 1.28, 1.19, 1.11, 1, 0.92, 0.86, 0.79, 0.76, 0.76, 0.76, 0.76, 0.92, 0.98, 1.03, 1.03, 1.03, 1.03, 1.07, 1.11, 1.24, 1.44, 2.12, 3.26, 15, 9.45, 5.07, 4.59, 3.5, 2.84, 2.54, 2.57, 3.01, 2.32, 2.32, 2.97, 2.92, 3.88, 4.76, 5.99, 3.74, 2.92, 2.65, 2.57, 2.97, 3.4, 4.13, 4.31, 3.89, 3.45, 3.01, 2.88, 2! .5, 2.29, 2.39, 2.25, 2.02, 1.87, 1.87, 2.54, 2.69, 2.76, 3.18, 3.74, 4.59, 4.76, 4.36, 6.56, 5.07, 3.84, 3.55, 3.84, 3.84, 5.49, 5.32, 3.74, 3.31, 3.4, 3.26, 3.09, 2.69, 2.54, 2.46, 2.39, 2.25, 2.22, 2.22, 2.25, 2.29, 2.22, 2.18, 2.05, 2.18, 2.39, 2.18, 2.29, 2.11, 1.81, 1.6, 1.44, 1.41, 1.32, 1.37, 1.37, 1.65, 2.31, 2.25, 1.68, 1.41, 1.26, 1.15, 3.28, 1.93, 1.6, 1.53, 1.28, 1.13, 1.03, 1.03, 1.03, 1.03, 1, 0.96, 0.92, 0.87, 0.82, 0.79, 0.76, 0.73, 0.7, 0.67, 0.64, 0.64, 0.61, 0.61, 0.61, 1.76, 1.19, 1.24, 1.37, 1.68, 2.39, 2.05, 1.78, 1.58, 1.41, 1.39, 1.5, 1.41, 1.32, 1.19, 1.11, 1.02, 1.07, 4.57, 1.96, 1.68, 1.5, 1.37, 1.24, 1.11, 1.03, 0.96, 0.94, 2.93, 2.88, 2.92, 2.76, 2.02, 1.71, 1.5, 1.37, 1.22, 1.09, 1, 0.94, 0.87, 0.81, 0.76, 0.73, 0.7, 0.67, 0.61, 0.58, 0.57, 0.55, 0.53, 0.51, 0.48, 0.47, 0.44, 0.43, 0.43, 0.41, 0.41, 0.38, 0.4, 0.4, 0.42, 0.42, 0.41, 0.46, 0.53, 0.55, 0.52, 0.49, 0.51, 0.53, 0.55, 0.7, 1.03, 1.03, 1.17, 1.24, 1.19, 1.11, 1.03, 0.98, 0.92, 0.84,! 0.79, 0.75, 0.7, 0.67, 0.61, 0.58, 0.56, 0.56, 0.55, 0.53, 0.51, 0.48 , 0.46, 0.43, 0.41, 0.38, 0.37, 0.35, 0.34, 0.32, 0.31, 0.3, 0.29, 0.28, 0.27, 0.25, 0.26, 0.24, 0.23, 0.22, 0.22, 0.21, 0.21, 0.21), b = c(0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.17, 0.16, 0.17, 0.17, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.16, 0.16, 0.17, 0.17, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.19, 0.21, 0.21, 0.21, 0.22, 0.23, 0.24, 0.24, 0.23, 0.24, 0.24, 0.25, 0.25, 0.25, 0.28, 0.29, 0.29, 0.3, 0.31, 0.31, 0.34, 0.41, 0.46, 0.51, 0.57, 0.61, 0.64, 0.67, 0.7, 0.76, 0.82, 0.86, 1.05, 1.24, 1.05, 0.94, 0.92, 0.9, 0.86, 0.82, 0.76, 0.76, 0.76, 0.78, 0.82, 0.9, 1.07, 1.76, 3.13, 3.64, 3.45, 3.01, 2.39, 2.02, 1.87, 2.11, 2.02, 1.78, 1.63, 1.53, 1.63, 4.84, 12.5, 8.11, 3.89, 2.73, 2.11, 1.96, 3.17, 2.65, 2.54, 3.01, 3.31, 3.6, 3.36, 2.76, 2.39, 2.11, 2.! 25, 2.08, 1.99, 2.11, 2.36, 3.13, 7.16, 5.39, 5.52, 5.32, 4.25, 3.45, 3.26, 3.18, 3.74, 4.35, 5.79, 5.45, 4.42, 3.84, 3.36, 2.84, 2.39, 3.84, 3.18, 3.22, 2.97, 2.73, 2.65, 2.92, 4.33, 3.01, 3.01, 3.26, 3.09, 3.6, 3.64, 4.05, 4.25, 4.48, 3.69, 3.74, 3.6, 3.18, 2.76, 4.11, 2.92, 2.69, 2.73, 2.69, 3.93, 2.69, 2.18, 2.52, 2.69, 1.99, 2.57, 1.81, 1.55, 1.44, 1.37, 1.28, 1.19, 1.19, 1.03, 1.03, 1, 0.94, 0.89, 0.87, 0.86, 0.86, 2.3, 1.55, 1.19, 1.11, 1.5, 1.39, 1.22, 1.24, 1.07, 1.02, 0.96, 0.92, 1.34, 1.15, 1.03, 2.06, 1.76, 1.3, 1.15, 1.05, 0.98, 0.92, 0.89, 0.84, 0.81, 0.76, 0.73, 1.59, 5.2, 3.01, 2.05, 1.65, 1.68, 5.29, 2.73, 1.96, 1.6, 1.41, 1.28, 1.15, 1.11, 1.13, 1.09, 1.03, 6.99, 10.6, 5.39, 3.45, 2.5, 1.87, 1.68, 1.78, 1.53, 1.41, 1.3, 1.17, 1.05, 0.98, 0.92, 0.9, 0.87, 0.86, 0.82, 0.78, 0.75, 0.72, 0.67, 0.82, 1.6, 0.89, 0.94, 0.96, 0.92, 0.87, 0.82, 0.79, 0.75, 0.7, 0.67, 0.64, 0.61, 0.58, 0.56, 0.53, 0.51, 0.48, 0.47, 0.46, 0.43, 0.41, 0.41, 0.68, 16.3, 17.2, 6.05, 3.6! 9, 2.92, 2.25, 1.87, 1.63, 1.46, 1.32, 1.19, 1.07, 1, 0.94, 0.89, 0.87 , 0.86, 0.81, 0.76, 0.73, 0.7, 0.7, 0.7, 0.7, 0.7, 0.67, 0.67, 0.66, 0.64, 0.61, 0.58, 0.56, 0.55, 0.53, 0.51, 0.48, 0.46, 0.44, 0.43, 0.43, 0.41, 0.4, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.32, 0.31, 0.31, 0.3, 0.3, 0.29, 0.29, 0.28, 0.27, 0.27), c = c(0.27, 0.25, 0.25, 0.25, 0.24, 0.24, 0.23, 0.22, 0.22, 0.21, 0.21, 0.21, 0.21, 0.21, 0.2, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.16, 0.15, 0.15, 0.15, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12,
[R] fractal package
Greetings of Peace! I am new in R software. I want to use the correlation dimension corrDim in computing a map. I have installed the packages(fractal) in R. Now my problem is this, when I tried your example in the following site http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=fractal:corrDim library(fractal) png(filename=corrDim_%03d_med.png, width=480, height=480) beam.d2 - corrDim(beamchaos, olag=10, dim=10, res=4) Warning messages: 1: In any(diff(x)) : coercing argument of type 'double' to logical 2: In any(diff(x)) : coercing argument of type 'double' to logical 3: In any(diff(x)) : coercing argument of type 'double' to logical 4: In any(diff(x)) : coercing argument of type 'double' to logical 5: In any(diff(x)) : coercing argument of type 'double' to logical 6: In any(diff(x)) : coercing argument of type 'double' to logical 7: In any(diff(x)) : coercing argument of type 'double' to logical 8: In any(diff(x)) : coercing argument of type 'double' to logical 9: In any(diff(x)) : coercing argument of type 'double' to logical 10: In any(diff(x)) : coercing argument of type 'double' to logical I cannot proceed because of the warning messages appeared. Is my installation correct? Please HELP me.. Thank you so much. Sincerely yours, Mary Joy Regidor Student MSU-IIT, Iligan City Philippines [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] why querying Sybase IQ using RODBC returns error ?
This is a known bug in Sybase's ODBC driver, and yes, the workarounds are documented in the package. Have you actually read the documentation? On 30/07/2012 05:51, Alok Jadhav wrote: Hello, I am not able to query Sybase IQ database from R using RODBC package. Check the below code R sybaseiq.query - function (sql, ..., as.is = FALSE) { connstr - Driver={Sybase IQ};UID=ajadhav2;PWD=*;ServerName=PSGSESHR01A_IQ;CommLinks=SharedMemory,TCPIP{host=psgseshr01_iq.sg.csfb.com;port=3051} chan - odbcDriverConnect(connstr) on.exit(odbcClose(chan)) if (length(list(...)) 0) sql - sprintf(sql, ...) x - sqlQuery(chan, sql, as.is = as.is) return(x) } R R R R x - sybaseiq.query(select * from syagprd1.orders where tradedate='120727' and acct='DVW') Error in .Call(C_RODBCFetchRows, attr(channel, handle_ptr), max, buffsize, : negative length vectors are not allowed R x [1] 42000 -131 [Sybase][ODBC Driver][Sybase IQ]Syntax error near 'order' on line 1 [2] [RODBC] ERROR: Could not SQLExecDirect 'select * from syagprd1.order where tradedate='120727' and acct='DVW' and ptag=-1 and sym='BHP.AX'' This is same behavior for empty datasets also R x - agora.query.iq(select * from syagprd1.orders where 1=2) Error in .Call(C_RODBCFetchRows, attr(channel, handle_ptr), max, buffsize, : negative length vectors are not allowed I am not sure what is wrong. Are their some arguments I need to know while I create chan to resolve this issue? Thanks for your help in advance. Regards, Alok -- View this message in context: http://r.789695.n4.nabble.com/why-querying-Sybase-IQ-using-RODBC-returns-error-tp4638297.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] NppToR-2.6.1
All, Have installed 'Notepad++', but require 'NppToR' to work with R. However, when I attempt to download from SourceForge NppToR-2.6.1.exe --- Internet Explorer blocks a Trojan Virus!?! Please advise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R- Help (looping)
Hello, Your code example doesn't make much sense, it needs decrypting. Let's see, for(k in 1:length(c1)){ if(c1[k] lcl | c1[k] ucl) {do something} } If this is it, then you can completely avoid the loop: i1 - c1 lcl | c1 ucl # create an index vector out.of.control - c1[ i1 ]# save the values When you say you have a column, is it a matrix column? data.frame? Give a data example with dput( head(myData, 20) ) # paste the output of this in a post Hope this helps, Rui Barradas Em 29-07-2012 21:59, Wellington G. Silva escreveu: Hi, I'm Wellington from Brazil and I have the following issue: I've been working on a project a for a while, and I'm having trouble in using the loop (for) I need to read a column (c1), and for each value of this column, I need to check if it's within the control limits So, I was trying to do this: For (k in 1: c1) If (c1 lcl1 | c1 ucl1) {here I need to store the values outside the limits) I have 5 columns, need to do the same process in each one of them. And later on I'm gonna concatenate these 5 vectors and calculate its mean for an ARL project. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NppToR-2.6.1
Hi, In what your problem is relevant to that list? Regards Le 30/07/2012 16:23, amarjit chandhial a écrit : All, Have installed 'Notepad++', but require 'NppToR' to work with R. However, when I attempt to download from SourceForge NppToR-2.6.1.exe --- Internet Explorer blocks a Trojan Virus!?! Please advise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem plotting in a grid
Did you actually read the help file for filled.contour? The image.plot call is being affected by the documented behavior of filled.contour. ggplot might be worth investigating. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Jonathan jonsle...@gmail.com wrote: Hi all, I'm trying to generate a grid of four plots. The first 2 appear just fine, but the final 2 will not appear in the grid, instead overwriting the first two.Any ideas on how to get them all in the same window would be greatly appreciated. Cheers, Jonathan library(fields) par(mfrow=c(2,2)) #2x2 plot windows plot(c(2,4),c(2,2)) # works fine plot(c(2,4),c(2,2)) # works fine x - 1:4 y - 5:10 z - matrix(0,length(x),length(y)) z2 - matrix(0,length(x),length(y)) for(i in 1:length(x)) { for (j in 1:length(y)) { z[i,j] - sample(4:10,1) z2[i,j] - sample(4:10,1) } } filled.contour(x,y,z,color.palette=topo.colors) # doesn't work image.plot(x,y,z2,add=TRUE) # doesn't work __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NppToR-2.6.1
So which list do I post to ? From: Pascal Oettli kri...@ymail.com To: amarjit chandhial a.chandh...@btinternet.com Cc: r-help@r-project.org r-help@r-project.org Sent: Monday, 30 July 2012, 8:29 Subject: Re: [R] NppToR-2.6.1 Hi, In what your problem is relevant to that list? Regards Le 30/07/2012 16:23, amarjit chandhial a écrit : All, Have installed 'Notepad++', but require 'NppToR' to work with R. However, when I attempt to download from SourceForge NppToR-2.6.1.exe --- Internet Explorer blocks a Trojan Virus!?! Please advise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NppToR-2.6.1
Hi, Try with another web browser. Regards. Le 30/07/2012 16:32, amarjit chandhial a écrit : So which list do I post to ? From: Pascal Oettli kri...@ymail.com To: amarjit chandhial a.chandh...@btinternet.com Cc: r-help@r-project.org r-help@r-project.org Sent: Monday, 30 July 2012, 8:29 Subject: Re: [R] NppToR-2.6.1 Hi, In what your problem is relevant to that list? Regards Le 30/07/2012 16:23, amarjit chandhial a écrit : All, Have installed 'Notepad++', but require 'NppToR' to work with R. However, when I attempt to download from SourceForge NppToR-2.6.1.exe --- Internet Explorer blocks a Trojan Virus!?! Please advise. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Assigning a new name to object loaded with load()
Hi, A bit late with my answer, but another possibility is to use to saveObject() / loadObject() functions from R.utils. I find it much easier to use than save() / load() Example: library(R.utils) x - 1:5 saveObject(x, file=test.Rbin) y - loadObject(test.Rbin) identical(x,y) HTH, Ivan -- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282 Biogéosciences 6 Boulevard Gabriel 21000 Dijon, FRANCE +33(0)3.80.39.63.06 ivan.calan...@u-bourgogne.fr http://biogeosciences.u-bourgogne.fr/calandra Le 28/07/12 06:11, Alireza Mahani a écrit : This works, thank you! I imagine that for large objects there will be a penalty for calling this function since the objects will be loaded and then copied as the function's return value. -- View this message in context: http://r.789695.n4.nabble.com/Assigning-a-new-name-to-object-loaded-with-load-tp4638144p4638182.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Turning off continuation prompt?
Greetings All. My apologies for a question whose answer is probably readily available somewhere (for some interpetation of somewhere) ... Say I have just typed (from a sheet of paper) several lines into the R command-line, and what I see is: chisq.test(matrix(c(3,6,3,4,4, + 4,1,4,6,5, + 2,7,4,2,5, + 8,2,4,4,2, + 3,4,5,4,4),ncol=5)) Later, I find that would like to re-input the data part of this command (matrix(c(...)...)). Without the + continuation prompts, it would be easy to do this by copypaste with the mouse in one operation. With the + marks there, I have to do the copypaste for each separate line. So is there a way to suppress the output of the + at the beginning of each continuation line? (The above is one of the smaller examples of this situation; sometimes I have wished to do this for commands extending over, say, 15-20 lines). With thanks, Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 30-Jul-2012 Time: 09:58:02 This message was sent by XFMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Turning off continuation prompt?
Hello, See the setting of options()$continue options(continue = ) Error in options(continue = ) : invalid value for 'continue' options(continue = ) x - 1:5 x [1] 1 2 3 4 5 Hope this helps, Rui Barradas Em 30-07-2012 09:58, (Ted Harding) escreveu: Greetings All. My apologies for a question whose answer is probably readily available somewhere (for some interpetation of somewhere) ... Say I have just typed (from a sheet of paper) several lines into the R command-line, and what I see is: chisq.test(matrix(c(3,6,3,4,4, + 4,1,4,6,5, + 2,7,4,2,5, + 8,2,4,4,2, + 3,4,5,4,4),ncol=5)) Later, I find that would like to re-input the data part of this command (matrix(c(...)...)). Without the + continuation prompts, it would be easy to do this by copypaste with the mouse in one operation. With the + marks there, I have to do the copypaste for each separate line. So is there a way to suppress the output of the + at the beginning of each continuation line? (The above is one of the smaller examples of this situation; sometimes I have wished to do this for commands extending over, say, 15-20 lines). With thanks, Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 30-Jul-2012 Time: 09:58:02 This message was sent by XFMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cannot install RSTAR, MSVAR, and MSVECM packages
*Hi all, I got problems installing RSTAR, MSVAR, and MSVECM packages. * install.packages(RSTAR)Installing package(s) into C:/Program Files/R/R-2.15.1/library (as lib is unspecified)Warning in install.packages : package RSTAR is not available (for R version 2.15.1) install.packages(MSVAR) Installing package(s) into C:/Program Files/R/R-2.15.1/library (as lib is unspecified) Warning in install.packages : package MSVAR is not available (for R version 2.15.1) install.packages(~/Downloads/MSVAR_0.0.tar.gz, repos = NULL) Installing package(s) into C:/Program Files/R/R-2.15.1/library (as lib is unspecified) Warning in install.packages : error 1 in extracting from zip file Warning in install.packages : cannot open compressed file 'MSVAR_0.0.tar.gz/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection install.packages(MSVECM)Installing package(s) into C:/Program Files/R/R-2.15.1/library (as lib is unspecified)Warning in install.packages : package MSVECM is not available (for R version 2.15.1) *Would someone help me to solve this problem? Best Regards Ario* [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NppToR-2.6.1
On Jul 30, 2012, at 09:38 , Pascal Oettli wrote: Hi, Try with another web browser. Regards. Le 30/07/2012 16:32, amarjit chandhial a écrit : So which list do I post to ? A better answer would be to go to http://sourceforge.net/projects/npptor/ and use the forums. I see three possible scenarios 1. IE is getting a false positive on a virus/trojan check (by itself or via an external virus scanner?) 2. You really do have an infected version 3. NppToR is doing things (like keypress generation) of which trojan scanners have become suspicious. -pd -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cannot install RSTAR, MSVAR, and MSVECM packages
On Jul 30, 2012, at 11:08 , Ario Ario wrote: *Hi all, I got problems installing RSTAR, MSVAR, and MSVECM packages. * No such thing exists on CRAN (nor its Archive section), so little wonder. Similarly named packages exist for the Ox matrix language, though. Such packages, however, do not readily convert themselves for use with R. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NppToR-2.6.1
Thanks Peter. I'll see the forums at SourceForge.net and try. Maybe RStudio is the best IDE for me. AC From: peter dalgaard pda...@gmail.com To: Pascal Oettli kri...@ymail.com Cc: amarjit chandhial a.chandh...@btinternet.com; r-help@r-project.org r-help@r-project.org Sent: Monday, 30 July 2012, 10:09 Subject: Re: [R] NppToR-2.6.1 On Jul 30, 2012, at 09:38 , Pascal Oettli wrote: Hi, Try with another web browser. Regards. Le 30/07/2012 16:32, amarjit chandhial a écrit : So which list do I post to ? A better answer would be to go to http://sourceforge.net/projects/npptor/ and use the forums. I see three possible scenarios 1. IE is getting a false positive on a virus/trojan check (by itself or via an external virus scanner?) 2. You really do have an infected version 3. NppToR is doing things (like keypress generation) of which trojan scanners have become suspicious. -pd -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] PLSR AND PCR ISSUES
You give us far too little information about what you do, what you want and what happens. Given that, the only help one can give is: Read the documentation. :) -- Regards, Bjørn-Helge Mevik, dr. scient, Research Computing Services, University of Oslo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Convert variable to STring
Dear all, I have a variable that I would like also to use it as a string. The reasons is that I want to collect results from different function to one table.. So when I use the colnames(mymatrix) -c(function1.function2,function3) the function1, function2, function3 to be converted to simple strings so as colnames(mymatrix) -c(function1,function2,function3) Could you please help me understand how I can do that in R? Regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] On Reproducible Code
Hadley, Thank you for posting this. I think the danger is that novices (and I'm not far removed from that category) can be intimidated by R, but more so by R experts that make people AFRAID to ask questions. The danger is that these intimidating R experts could turn people away from using R; at the very least, novices could end up wasting valuable time trying to complete their projects because they can't get the help they are searching for. Nothing is gained by punishing people over their internet 'manners' Tom On Fri, Jul 27, 2012 at 1:47 PM, Hadley Wickham had...@rice.edu wrote: That assumes: * Everyone reads the mailing list before making the first posting * Everyone reads every part of every email. I'd argue that both assumptions are false. People are particular well trained to skip over boilerplate text at the bottom of emails. I'd suggest an alternative approach is for experts to remember what it's like to be a novice, and cultivate an attitude of patience and tolerance. That's about as likely to happen as a mass change in behaviour in new users. Hadley On Fri, Jul 27, 2012 at 9:48 AM, John Kane jrkrid...@inbox.com wrote: I'd vote for that! It would probably bug the blazes out of experienced users but the time savings in getting a newbie to actually supply enough information so that someone can, at least, try to answer the question would be well worth it. John Kane Kingston ON Canada -Original Message- From: gunter.ber...@gene.com Sent: Fri, 27 Jul 2012 07:49:28 -0700 To: jrkrid...@inbox.com Subject: Re: [R] On Reproducible Code I agree and would like to see it placed at the **TOP** of every post. -- Bert On Fri, Jul 27, 2012 at 7:11 AM, John Kane jrkrid...@inbox.com wrote: -Original Message- From: j...@bitwrit.com.au Sent: Fri, 27 Jul 2012 19:21:36 +1000 To: dcarl...@tamu.edu Subject: Re: [R] On Reproducible Code On 07/26/2012 01:50 AM, David L Carlson wrote: We often refer requesters to the Posting Guide and chide them for not reading it. ... I hesitate to sound too optimistic, but there might be some advantage in making the statement more prominent and adding a reproducible example using dput(). The reponses to some requests for help do seem to get a volley of the reproducible code answers. Some, such as: I can't get the answer. PLEASE HELP!!! probably deserve it, but others appear to emerge from the overheated brain of the frustrated noob. With a wonderfully informative name like dput, it is rather challenging to guess that this function is the way to calm the affronted guru with an example of your problem. I am particularly amused by the phrase reproducible code, which sounds perilously close to the definition of a virus. Perhaps the neglected little message at the bottom of each email (which seems to reproduce itself) might be easier for the uninitiated to understand if it read: Please include the R code that is causing the problem _and_ enough data (see the dput function) for someone else to run the code and get the same problem. I can remember when I didn't know that there was a dput function. Jim I can remember spending a lot of time constructing a data set to post before someone mentioned ?dput. Ah, yes, I still have a couple of generic ones archived. I think your wording above makes a lot of sense. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk and most webmails __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,
Re: [R] Turning off continuation prompt?
On Mon, Jul 30, 2012 at 4:58 AM, Ted Harding ted.hard...@wlandres.net wrote: Greetings All. My apologies for a question whose answer is probably readily available somewhere (for some interpetation of somewhere) ... Say I have just typed (from a sheet of paper) several lines into the R command-line, and what I see is: chisq.test(matrix(c(3,6,3,4,4, + 4,1,4,6,5, + 2,7,4,2,5, + 8,2,4,4,2, + 3,4,5,4,4),ncol=5)) Later, I find that would like to re-input the data part of this command (matrix(c(...)...)). Without the + continuation prompts, it would be easy to do this by copypaste with the mouse in one operation. With the + marks there, I have to do the copypaste for each separate line. So is there a way to suppress the output of the + at the beginning of each continuation line? (The above is one of the smaller examples of this situation; sometimes I have wished to do this for commands extending over, say, 15-20 lines). On Windows just copy the command to the clipboard and the use Edit | Paste Commands to paste them back (as opposed to just Paste) in and it will remove the leading junk on each line as it pastes it in. Another possibility which is not specific to Windows is to issue: history() and then copy from the history -- the history output has no leading junk in the first place. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with tensor factorization
Hi, thank Petr for your help. I have implemented you code suggestion but there is another problem. It seems that the code: for (i in 1:m){ Z[i,,]=table(occ, data_matrix[,i]) } don't charge any values in Z. Is there some error? Thanks. Giuseppe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with tensor factorization
On Mon, Jul 30, 2012 at 01:09:34PM +0200, Peppe Ricci wrote: Hi, thank Petr for your help. I have implemented you code suggestion but there is another problem. It seems that the code: for (i in 1:m){ Z[i,,]=table(occ, data_matrix[,i]) } don't charge any values in Z. Is there some error? Hi. I already deleted your previous emails from my folder and you start a new thread. Can you recall, what is exactly the problem and which code you use? Without a context, the reason for the above problem cannot be understood. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] On Reproducible Code
On Jul 30, 2012, at 13:05 , Thomas Adams wrote: Nothing is gained by punishing people over their internet 'manners'∑ Tom On the contrary, everything can be lost by allowing abusers to persevere! (And yes, there are people who no longer attempt to help, because of ungrateful and downright arrogant behavior they have experienced on the lists.) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] On Reproducible Code
Peter, You may have misunderstood me (I did not define correctly whose internet manners I was referring to) â I was referring to the internet manners of those seeking help, that, yes, they may not have adequately researched things before asking a question, or may not have supplied a reproducible example, etc., but they don't deserve to be treated disrespectfully â I think we are agreeing on this⦠Tom On Mon, Jul 30, 2012 at 8:02 AM, peter dalgaard pda...@gmail.com wrote: On Jul 30, 2012, at 13:05 , Thomas Adams wrote: Nothing is gained by punishing people over their internet 'manners'â Tom On the contrary, everything can be lost by allowing abusers to persevere! (And yes, there are people who no longer attempt to help, because of ungrateful and downright arrogant behavior they have experienced on the lists.) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: thomas.ad...@noaa.gov VOICE: 937-383-0528 FAX:937-383-0033 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cluster of points
Hello: What I want to do is quite simple, but I can't find a way. I have a data frame with several points (x and y coords). I want to add another column with cluster membership. For example aggregate all the points that stand within a distance of 40 from each other. I've tried using nncluster from the package nnclust, but the results are not correct, for some reason (probably my mistake). This is what I did: x - nncluster(as.matrix(dframe[,1:2]), threshold=35, fill = 1, maxclust = NULL, give.up = 500,verbose=FALSE,start=NULL)#avaliar as clusters Thanks, Frederico [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Convert variable to STring
Can you give us an example of what you mean by the functions listed below. Otherwise something like this seems to work xx - 1 :4 x1 - as.character(xx) mat - matrix(1:12, nrow=3) John Kane Kingston ON Canada -Original Message- From: ala...@yahoo.com Sent: Mon, 30 Jul 2012 03:47:45 -0700 (PDT) To: r-help@r-project.org Subject: [R] Convert variable to STring Dear all, I have a variable that I would like also to use it as a string. The reasons is that I want to collect results from different function to one table.. So when I use the colnames(mymatrix) -c(function1.function2,function3) the function1, function2, function3 to be converted to simple strings so as colnames(mymatrix) -c(function1,function2,function3) Could you please help me understand how I can do that in R? Regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Turning off continuation prompt?
If I understand the question correctly the answer is probably not to type anything at the R command line. A good editor or interface is a better approach http://en.wikipedia.org/wiki/R_%28programming_language%29#Interfaces John Kane Kingston ON Canada -Original Message- From: ted.hard...@wlandres.net Sent: Mon, 30 Jul 2012 09:58:09 +0100 (BST) To: r-help@r-project.org Subject: [R] Turning off continuation prompt? Greetings All. My apologies for a question whose answer is probably readily available somewhere (for some interpetation of somewhere) ... Say I have just typed (from a sheet of paper) several lines into the R command-line, and what I see is: chisq.test(matrix(c(3,6,3,4,4, + 4,1,4,6,5, + 2,7,4,2,5, + 8,2,4,4,2, + 3,4,5,4,4),ncol=5)) Later, I find that would like to re-input the data part of this command (matrix(c(...)...)). Without the + continuation prompts, it would be easy to do this by copypaste with the mouse in one operation. With the + marks there, I have to do the copypaste for each separate line. So is there a way to suppress the output of the + at the beginning of each continuation line? (The above is one of the smaller examples of this situation; sometimes I have wished to do this for commands extending over, say, 15-20 lines). With thanks, Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 30-Jul-2012 Time: 09:58:02 This message was sent by XFMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Convert variable to STring
You may be searching for the deparse(substitute(x)) idiom. Michael On Jul 30, 2012, at 5:47 AM, Alaios ala...@yahoo.com wrote: Dear all, I have a variable that I would like also to use it as a string. The reasons is that I want to collect results from different function to one table.. So when I use the �colnames(mymatrix) -c(function1.function2,function3) the function1, function2, function3 to be converted to simple strings so as �colnames(mymatrix) -c(function1,function2,function3) Could you please help me understand how I can do that in R? Regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] distance matrix and hclustering
Look at the examples for the functions dist() and hclust(), ?dist ?hclust Jean eliza botto eliza_bo...@hotmail.com wrote on 07/30/2012 01:43:55 AM: Dear R Users,i am very new to R. I want your help on an issue regarding distance matrix and cluster analysis i had discharge data of 4 rivers(a,b,c,d) in 4 vectors each having 364 values dput(qmu)structure(list(a = c(0.26, 0.25, 0.25, 0.25, 0.24, 0.23, 0.22, 0.21, 0.21, 0.21, 0.2, 0.19, 0.19, 0.19, 0.19, 0.18, 0.18, 0. 18, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0. 17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.18, 0.19, 0.19, 0.19, 0.2, 0.21, 0.21, 0.21, 0.21, 0.21, 0.21, 0.19, 0.19, 0.18, 0.17, 0.17, 0.15, 0. 18, 0.2, 0.21, 0.2, 0.19, 0.19, 0.19, 0.2, 0.24, 0.3, 0.3, 0.3, 0. 32, 0.34, 0.42, 0.46, 0.48, 0.67, 0.82, 0.79, 0.73, 0.69, 0.67, 0. 67, 0.66, 0.64, 0.61, 0.58, 0.56, 0.55, 0.55, 0.55, 0.52, 0.49, 0. 48, 0.51, 0.53, 0.52, 0.49, 0.48, 0.48, 0.46, 0.46, 0.44, 0.43, 0. 43, 0.41, 0.48, 0.55, 0.57, 0.55, 0.56, 0.6, 0.64, 0.67, 0.73, 0.84, 0.94, 1.09, 1.24, 1.28, 1.19, 1.11, 1, 0.92, 0.86, 0.79, 0.76, 0.76, 0.76, 0.76, 0.92, 0.98, 1.03, 1.03, 1.03, 1.03, 1.07, 1.11, 1.24, 1. 44, 2.12, 3.26, 15, 9.45, 5.07, 4.59, 3.5, 2.84, 2.54, 2.57, 3.01, 2.32, 2.32, 2.97, 2.92, 3.88, 4.76, 5.99, 3.74, 2.92, 2.65, 2.57, 2. 97, 3.4, 4.13, 4.31, 3.89, 3.45, 3.01, 2.88, 2! .5, 2.29, 2.39, 2.25, 2.02, 1.87, 1.87, 2.54, 2.69, 2.76, 3.18, 3. 74, 4.59, 4.76, 4.36, 6.56, 5.07, 3.84, 3.55, 3.84, 3.84, 5.49, 5. 32, 3.74, 3.31, 3.4, 3.26, 3.09, 2.69, 2.54, 2.46, 2.39, 2.25, 2.22, 2.22, 2.25, 2.29, 2.22, 2.18, 2.05, 2.18, 2.39, 2.18, 2.29, 2.11, 1. 81, 1.6, 1.44, 1.41, 1.32, 1.37, 1.37, 1.65, 2.31, 2.25, 1.68, 1.41, 1.26, 1.15, 3.28, 1.93, 1.6, 1.53, 1.28, 1.13, 1.03, 1.03, 1.03, 1. 03, 1, 0.96, 0.92, 0.87, 0.82, 0.79, 0.76, 0.73, 0.7, 0.67, 0.64, 0. 64, 0.61, 0.61, 0.61, 1.76, 1.19, 1.24, 1.37, 1.68, 2.39, 2.05, 1. 78, 1.58, 1.41, 1.39, 1.5, 1.41, 1.32, 1.19, 1.11, 1.02, 1.07, 4.57, 1.96, 1.68, 1.5, 1.37, 1.24, 1.11, 1.03, 0.96, 0.94, 2.93, 2.88, 2. 92, 2.76, 2.02, 1.71, 1.5, 1.37, 1.22, 1.09, 1, 0.94, 0.87, 0.81, 0. 76, 0.73, 0.7, 0.67, 0.61, 0.58, 0.57, 0.55, 0.53, 0.51, 0.48, 0.47, 0.44, 0.43, 0.43, 0.41, 0.41, 0.38, 0.4, 0.4, 0.42, 0.42, 0.41, 0. 46, 0.53, 0.55, 0.52, 0.49, 0.51, 0.53, 0.55, 0.7, 1.03, 1.03, 1.17, 1.24, 1.19, 1.11, 1.03, 0.98, 0.92, 0.84,! 0.79, 0.75, 0.7, 0.67, 0.61, 0.58, 0.56, 0.56, 0.55, 0.53, 0.51, 0.48 , 0.46, 0.43, 0.41, 0.38, 0.37, 0.35, 0.34, 0.32, 0.31, 0.3, 0.29, 0.28, 0.27, 0.25, 0.26, 0.24, 0.23, 0.22, 0.22, 0.21, 0.21, 0.21), b = c(0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.17, 0. 16, 0.17, 0.17, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0. 15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.14, 0.14, 0. 14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0. 14, 0.14, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.16, 0.16, 0. 17, 0.17, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.19, 0. 21, 0.21, 0.21, 0.22, 0.23, 0.24, 0.24, 0.23, 0.24, 0.24, 0.25, 0. 25, 0.25, 0.28, 0.29, 0.29, 0.3, 0.31, 0.31, 0.34, 0.41, 0.46, 0.51, 0.57, 0.61, 0.64, 0.67, 0.7, 0.76, 0.82, 0.86, 1.05, 1.24, 1.05, 0. 94, 0.92, 0.9, 0.86, 0.82, 0.76, 0.76, 0.76, 0.78, 0.82, 0.9, 1.07, 1.76, 3.13, 3.64, 3.45, 3.01, 2.39, 2.02, 1.87, 2.11, 2.02, 1.78, 1. 63, 1.53, 1.63, 4.84, 12.5, 8.11, 3.89, 2.73, 2.11, 1.96, 3.17, 2. 65, 2.54, 3.01, 3.31, 3.6, 3.36, 2.76, 2.39, 2.11, 2.! 25, 2.08, 1.99, 2.11, 2.36, 3.13, 7.16, 5.39, 5.52, 5.32, 4.25, 3. 45, 3.26, 3.18, 3.74, 4.35, 5.79, 5.45, 4.42, 3.84, 3.36, 2.84, 2. 39, 3.84, 3.18, 3.22, 2.97, 2.73, 2.65, 2.92, 4.33, 3.01, 3.01, 3. 26, 3.09, 3.6, 3.64, 4.05, 4.25, 4.48, 3.69, 3.74, 3.6, 3.18, 2.76, 4.11, 2.92, 2.69, 2.73, 2.69, 3.93, 2.69, 2.18, 2.52, 2.69, 1.99, 2. 57, 1.81, 1.55, 1.44, 1.37, 1.28, 1.19, 1.19, 1.03, 1.03, 1, 0.94, 0.89, 0.87, 0.86, 0.86, 2.3, 1.55, 1.19, 1.11, 1.5, 1.39, 1.22, 1. 24, 1.07, 1.02, 0.96, 0.92, 1.34, 1.15, 1.03, 2.06, 1.76, 1.3, 1.15, 1.05, 0.98, 0.92, 0.89, 0.84, 0.81, 0.76, 0.73, 1.59, 5.2, 3.01, 2. 05, 1.65, 1.68, 5.29, 2.73, 1.96, 1.6, 1.41, 1.28, 1.15, 1.11, 1.13, 1.09, 1.03, 6.99, 10.6, 5.39, 3.45, 2.5, 1.87, 1.68, 1.78, 1.53, 1. 41, 1.3, 1.17, 1.05, 0.98, 0.92, 0.9, 0.87, 0.86, 0.82, 0.78, 0.75, 0.72, 0.67, 0.82, 1.6, 0.89, 0.94, 0.96, 0.92, 0.87, 0.82, 0.79, 0. 75, 0.7, 0.67, 0.64, 0.61, 0.58, 0.56, 0.53, 0.51, 0.48, 0.47, 0.46, 0.43, 0.41, 0.41, 0.68, 16.3, 17.2, 6.05, 3.6! 9, 2.92, 2.25, 1.87, 1.63, 1.46, 1.32, 1.19, 1.07, 1, 0.94, 0.89, 0.87 , 0.86, 0.81, 0.76, 0.73, 0.7, 0.7, 0.7, 0.7, 0.7, 0.67, 0.67, 0.66, 0.64, 0.61, 0.58, 0.56, 0.55, 0.53, 0.51, 0.48, 0.46, 0.44, 0.43, 0. 43, 0.41, 0.4, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.32, 0.31, 0.31, 0.3, 0.3, 0.29, 0.29, 0.28, 0.27, 0.27), c = c(0.27, 0.25, 0.25, 0. 25, 0.24, 0.24, 0.23, 0.22, 0.22, 0.21, 0.21, 0.21, 0.21, 0.21, 0.2, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0. 19, 0.19, 0.19, 0.18,
[R] APIs and R
Dear List, I am compiling a list of R packages that work with social media APIs. Uptil now I have found that 1- Most of these are based on RCurl, XML, rjson 2- Even though the API format is standardized for REST- there seems to be many differences within the APIs, leadinbg to multiple packages that do the required API call - 3- I am specific issues with the following Google +API access through R Linkedin API access through R Twitter +API access through ROAuth and Datasift API (basically a firehose for all social media) within R Again most of the APIs I find have libraries supported by java, ruby,python,curl- but there seems to be some overlooking of R within various API vendors. Has anybody been working with R for social media- I am specifically looking for use cases that avoid rate limiting of free api- and specifically OAuth and APis for LinkedIn, Google + and Datasift using R. Many Thanks, Ajay ohri Websites- Technology http://decisionstats.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] If/then statement, if in a list then
I need to write an if/then statement saying something along the lines of: if (VALUE is in list) {... How do I write that in R's language. Thanks! -- View this message in context: http://r.789695.n4.nabble.com/If-then-statement-if-in-a-list-then-tp4638346.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If/then statement, if in a list then
if(cond) expr if(cond) cons.expr else alt.expr Also see ?ifelse John Kane Kingston ON Canada -Original Message- From: bunnylove...@optonline.net Sent: Mon, 30 Jul 2012 05:55:34 -0700 (PDT) To: r-help@r-project.org Subject: [R] If/then statement, if in a list then I need to write an if/then statement saying something along the lines of: if (VALUE is in list) {... How do I write that in R's language. Thanks! -- View this message in context: http://r.789695.n4.nabble.com/If-then-statement-if-in-a-list-then-tp4638346.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If/then statement, if in a list then
?is.element Jean cm bunnylove...@optonline.net wrote on 07/30/2012 07:55:34 AM: I need to write an if/then statement saying something along the lines of: if (VALUE is in list) {... How do I write that in R's language. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If/then statement, if in a list then
Thank you so much Jean! -- View this message in context: http://r.789695.n4.nabble.com/If-then-statement-if-in-a-list-then-tp4638346p4638351.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MANOVA polynomial contrasts
Dear Gian Mauro, On Mon, 30 Jul 2012 14:44:44 +0200 Manzoni, GianMauro gm.manz...@auxologico.it wrote: Dear Prof. John Fox, thank you very much for your suggestions. However, I still do not know how to use the contrasts after generating them. Once I generate the matrix with the polynomial contrasts, what are the following steps toward the statistical test? Here's a contrived example, which uses the Anova() and linearHypothesis() functions in the car package: - snip -- Y - matrix(rnorm(300), 100, 3) colnames(Y) - c(y1, y2, y3) f - ordered(sample(letters[1:4], 100, replace=TRUE)) (mod - lm(Y ~ f)) Call: lm(formula = Y ~ f) Coefficients: y1y2y3 (Intercept) 0.06514 -0.01683 -0.13787 f.L -0.37837 0.18309 0.29736 f.Q -0.02102 -0.39894 0.08455 f.C 0.05898 0.09358 -0.17634 Anova(mod) Type II MANOVA Tests: Pillai test statistic Df test stat approx F num Df den Df Pr(F) f 3 0.11395 1.2634 9288 0.2566 linearHypothesis(mod, f.L) Sum of squares and products for the hypothesis: y1y2y3 y1 3.607260 -1.745560 -2.834953 y2 -1.745560 0.844680 1.371839 y3 -2.834953 1.371839 2.227995 Sum of squares and products for error: y1y2y3 y1 86.343376 -8.054928 -3.711756 y2 -8.054928 95.473020 2.429151 y3 -3.711756 2.429151 89.593163 Multivariate Tests: Df test stat approx F num Df den Df Pr(F) Pillai1 0.0648520 2.172951 3 94 0.096362 . Wilks 1 0.9351480 2.172951 3 94 0.096362 . Hotelling-Lawley 1 0.0693495 2.172951 3 94 0.096362 . Roy 1 0.0693495 2.172951 3 94 0.096362 . --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 - snip -- You could do similar tests for the quadratic and cubic contrasts. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ A whole example would be very useful. Thank you very much in advance! Best regards, Gian Mauro Manzoni 2012/7/25 John Fox j...@mcmaster.ca Dear Gian, How contrasts are created by default is controlled by the contrasts option: getOption(contrasts) unordered ordered contr.treatment contr.poly So, unless you've changed this option, contr.poly() will be used to generate orthogonal polynomial contrasts for an ordered factor, and you therefore need do nothing special to get this result. For example: (f - ordered(sample(letters[1:3], 10, replace=TRUE))) [1] c c a a c c b c a c Levels: a b c round(contrasts(f), 4) .L .Q [1,] -0.7071 0.4082 [2,] 0. -0.8165 [3,] 0.7071 0.4082 For more information, see section 11 on statistical models in the manual An Introduction to R, which is part of the standard R distribution, and in particular sections 11.1 and 11.1.1. I hope that this clarifies the issue. Best, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 25 Jul 2012 11:58:30 +0200 Manzoni, GianMauro gm.manz...@auxologico.it wrote: Dear Greg Snow, thank you very much for your suggestions. However, I need an example in order to understand fully. I was told that, given the ordinal factor, I do not need to specify the contr.poly function because R does it automatically. However, I don not know if I have to add an argument into the manova/anova function or something else. Please write me an illustrative example. Many thanks. Best regards, Gian Mauro Manzoni 2012/7/25 Greg Snow 538...@gmail.com You should not need to write them yourself. Look at the contr.poly function along with the C function (Note uppercase C) or the contrasts function. On Monday, July 23, 2012, Manzoni, GianMauro wrote: Dear all, I am quite new to R and I am having trouble writing the polynomial contrasts for an ordinal factor in MANOVA. # I have a model such as this fit-manova(cbind(Y1,Y2,Y3)~Groups,data=Events) # where groups is an ordinal factor with 4 levels # how to set polynomial contrasts for the Groups factor ? Thank you very much in advance for any help! Best regards, Mauro -- Dr. Gian Mauro Manzoni PhD, PsyD Psychology Research Laboratory San Giuseppe Hospital Istituto Auxologico Italiano Verbania - Italy e-mail: gm.manz...@auxologico.it cell. phone +39 338 4451207 Tel. +39 0323 514278 [[alternative HTML version deleted]]
Re: [R] Turning off continuation prompt?
Dear Ted, I don't think that it's really advisable to do so, because it might lead to confusion, but you could set options(continue= ). Best, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Mon, 30 Jul 2012 09:58:09 +0100 (BST) (Ted Harding) ted.hard...@wlandres.net wrote: Greetings All. My apologies for a question whose answer is probably readily available somewhere (for some interpetation of somewhere) ... Say I have just typed (from a sheet of paper) several lines into the R command-line, and what I see is: chisq.test(matrix(c(3,6,3,4,4, + 4,1,4,6,5, + 2,7,4,2,5, + 8,2,4,4,2, + 3,4,5,4,4),ncol=5)) Later, I find that would like to re-input the data part of this command (matrix(c(...)...)). Without the + continuation prompts, it would be easy to do this by copypaste with the mouse in one operation. With the + marks there, I have to do the copypaste for each separate line. So is there a way to suppress the output of the + at the beginning of each continuation line? (The above is one of the smaller examples of this situation; sometimes I have wished to do this for commands extending over, say, 15-20 lines). With thanks, Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 30-Jul-2012 Time: 09:58:02 This message was sent by XFMail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Turning off continuation prompt?
On Mon, 30 Jul 2012 09:58:09 +0100 (BST) (Ted Harding) ted.hard...@wlandres.net wrote: Greetings All. My apologies for a question whose answer is probably readily available somewhere (for some interpetation of somewhere) ... Say I have just typed (from a sheet of paper) several lines into the R command-line, and what I see is: chisq.test(matrix(c(3,6,3,4,4, + 4,1,4,6,5, + 2,7,4,2,5, + 8,2,4,4,2, + 3,4,5,4,4),ncol=5)) Later, I find that would like to re-input the data part of this command (matrix(c(...)...)). Without the + continuation prompts, it would be easy to do this by copypaste with the mouse in one operation. With the + marks there, I have to do the copypaste for each separate line. So is there a way to suppress the output of the + at the beginning of each continuation line? At some level of complexity it is worth thinking of using a programming front end to R rather than the basic GUI. I have really benefited from downloading RStudio myself, but there are any number of other choices that might be suited to your needs as well. Knowing how long you have been around this list, you probably can name more than I. Rob __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If/then statement, if in a list then
Not necessarily. If the OP really meant the R list() structure, then is.element does not apply. If a vector was what was intended, then it does -- provide all elements are of the same mode. With such a vague post, it's hard to know. -- Bert On Mon, Jul 30, 2012 at 6:06 AM, Jean V Adams jvad...@usgs.gov wrote: ?is.element Jean cm bunnylove...@optonline.net wrote on 07/30/2012 07:55:34 AM: I need to write an if/then statement saying something along the lines of: if (VALUE is in list) {... How do I write that in R's language. Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using save() to work with objects that exceed memory capacity
On Sun, Jul 29, 2012 at 7:08 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Sat, Jul 28, 2012 at 10:48 AM, David Romano roma...@grinnell.edu wrote: Context: I'm relatively new to R and am working with very large datasets. General problem: If working on a dataset requires that I produce more than two objects of roughly the size of the dataset, R quickly uses up its available memory and slows to a virtual halt. My tentative solution: To save and remove objects as they're created, and load them when I need them. To do this I'm trying to automatically generate file names derived from these objects, and use these in save(). My specific question to the list: How do I capture the string that names an object I want to save, in such a way that I can use it in a function that calls save()? For example, suppose I create a matrix and then save it follows: mat-matrix(1:9,3,3) save(mat, file=matfile) Then I get a file of the kind I'd like: the command 'load(matfile)' retrieves the correct matrix, with the original name 'mat'. Further, if I instead save it this way: objectname-mat save(list=ls(pattern=objectname), file=matfile) then I get the same positive result. But now suppose I create a function saveobj - function(objectname,objectfile) + { + save(list=ls(pattern=objectname),file=objectfile); + return()}; Then if I now try to save 'mat' by matname-mat saveobj(matname,matfile) I do not get the same result; namely, the command 'load(mat)' retrieves no objects. Why is this? load(matfile) no? Yes. It seems to work for me: R x - matrix(1:9, ncol = 3) R saveobj - function(obj, file){ + save(list = obj, file = file) + } R exists(x) [1] FALSE R saveobj(x, amatrix.rdat) R rm(x) R load(amatrix.rdat) R x [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 Cheers, Michael Thanks, Michael, for locating the trouble in the unessary call to ls(), and thanks to Duncan Murdoch, too, for pointing out how ls() was causing the observed behavior: without including an argument like envir=parent.frame(), ls() only returns local objects created after the call to saveobj. Very helpful -- thanks to you both! Best, David I'd be grateful for any help on either my specific questions, or suggestions of a better ways to address the issue of limited memory. Thanks, David Romano [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] If equal statement for character objects
I have a data frame (trans) 123 P 143 z ...ect I want to write a statement that says: if ((trans[i,2]=p)(trans[1+1,2]=z)){ but I get the warning message that states: operations are possible only for numeric, logical or complex types Any ideas? Thanks -- View this message in context: http://r.789695.n4.nabble.com/If-equal-statement-for-character-objects-tp4638359.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If equal statement for character objects
nevermind. all.equal() works! -- View this message in context: http://r.789695.n4.nabble.com/If-equal-statement-for-character-objects-tp4638359p4638361.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] A matching problem
Dear all, I was encountering with a typical Matching problem and was wondering whether R can help me to solve it directly. Let say, I have 2 vectors of equal length: vector1 - LETTERS[1:6] vector2 - letters[1:6] Now I need to match these 2 vectors with all possible ways like: (A,B,C,D,E) (a,b,c,d,e) is 1 match. Another match can be (A,B,C,D,E) (b,a,c,d,e), however there cant be any duplication. Is there any direct way to doing that in R? Thanks and regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] use R to read/print the system hardware configuration
Dear All, I am curious if there is any why to use R to know the specification of the machine that runs on, i.e. read the cpu model, memory size, those hardware info, maybe even with thesoftware information. Thank you for your attention. Best wishes, Jie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] locked binding of setwd() in R 2.15.x causes .Rprofile to fail
[Env: Win XP, R 2.14.2, R 2.15.0] I have a replacement function for setwd() in my .Rprofile which displays the current R path in the R window title. It no longer works in R 2.15.x, giving the error below. Worse, the error prevents the rest of my .Rprofile script from completing. Is there some way to rescue this, i.e., preserve this behavior in R 2.15? If not, how can I modify my script so it will still work under R 2.14.2 and not fail under R 2.15? Error in utils::assignInNamespace(setwd, function(dir) { : locked binding of ‘setwd’ cannot be changed ## #-- functions from .Rprofile # modify setwd() to also show the current path in the window title # assigns .lastdir in the global environment local({ oldsetwd - setwd utils::assignInNamespace(setwd, function(dir) { .lastdir - oldsetwd(dir) utils::setWindowTitle( short.path(base::getwd()) ) .lastdir }, base) }) # setwd replacement, allowing cd() to be like 'cd -' on unix (return to last dir) cd - function(dir) { if(missing(dir)) dir - .lastdir .lastdir - base::setwd(dir) utils::setWindowTitle( short.path(base::getwd()) ) } short.path - function(dir, len=2) { np -length(parts - unlist(strsplit(dir, '/'))) parts -rev( rev(parts)[1:min(np,len)] ) dots - ifelse (nplen, '...', '') paste(dots,paste(parts, '/', sep='', collapse='')) } -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] locked binding of setwd() in R 2.15.x causes .Rprofile to fail
Does trace() do what you want from a .Rprofile file? It works from the command line: trace(setwd,print=FALSE,quote(options(prompt=paste0(dir, Tracing function setwd in package base [1] setwd setwd(z:/) z:/ getwd() [1] z:/ z:/ setwd(c:/temp) c:/temp pi [1] 3.141593 c:/temp Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Friendly Sent: Monday, July 30, 2012 8:11 AM To: R-help Subject: [R] locked binding of setwd() in R 2.15.x causes .Rprofile to fail [Env: Win XP, R 2.14.2, R 2.15.0] I have a replacement function for setwd() in my .Rprofile which displays the current R path in the R window title. It no longer works in R 2.15.x, giving the error below. Worse, the error prevents the rest of my .Rprofile script from completing. Is there some way to rescue this, i.e., preserve this behavior in R 2.15? If not, how can I modify my script so it will still work under R 2.14.2 and not fail under R 2.15? Error in utils::assignInNamespace(setwd, function(dir) { : locked binding of 'setwd' cannot be changed ## #-- functions from .Rprofile # modify setwd() to also show the current path in the window title # assigns .lastdir in the global environment local({ oldsetwd - setwd utils::assignInNamespace(setwd, function(dir) { .lastdir - oldsetwd(dir) utils::setWindowTitle( short.path(base::getwd()) ) .lastdir }, base) }) # setwd replacement, allowing cd() to be like 'cd -' on unix (return to last dir) cd - function(dir) { if(missing(dir)) dir - .lastdir .lastdir - base::setwd(dir) utils::setWindowTitle( short.path(base::getwd()) ) } short.path - function(dir, len=2) { np -length(parts - unlist(strsplit(dir, '/'))) parts -rev( rev(parts)[1:min(np,len)] ) dots - ifelse (nplen, '...', '') paste(dots,paste(parts, '/', sep='', collapse='')) } -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use R to read/print the system hardware configuration
On 30/07/2012 16:08, Jie wrote: Dear All, I am curious if there is any why to use R to know the specification of the machine that runs on, i.e. read the cpu model, memory size, those hardware info, maybe even with thesoftware information. Thank you for your attention. There are ways ... however, there are no remotely portable ways and you have not even told us your OS (as asked for in the posting guide). This sort of thing depends not just on the OS but the precise version of the OS. Look at paralllel::detectCores() for how hard one has to work to get the number of processors. Best wishes, Jie [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use R to read/print the system hardware configuration
Sorry to miss the OS information. I run it on Window 7 32 bit, 64 bit and Unix (version unclear, it is a grid machine.) Best wishes, Jie On Mon, Jul 30, 2012 at 11:39 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On 30/07/2012 16:08, Jie wrote: Dear All, I am curious if there is any why to use R to know the specification of the machine that runs on, i.e. read the cpu model, memory size, those hardware info, maybe even with thesoftware information. Thank you for your attention. There are ways ... however, there are no remotely portable ways and you have not even told us your OS (as asked for in the posting guide). This sort of thing depends not just on the OS but the precise version of the OS. Look at paralllel::detectCores() for how hard one has to work to get the number of processors. Best wishes, Jie [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~**ripley/http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A matching problem
Is this what you want: vector1 - sample(LETTERS[1:6]) # randomize vector2 - letters[1:6] # convert to lower case for matching vector1 - tolower(vector1) vector2 - tolower(vector2) # count the number of matches so order does not matter count - match(vector1, vector2) if (length(count[!is.na(count)]) == length(vector1)) print(match) else print('no match') [1] match vector1 - sample(letters, 6) vector1 [1] d o t z g q count - match(vector1, vector2) if (length(count[!is.na(count)]) == length(vector1)) print(match) else print('no match') [1] no match On Mon, Jul 30, 2012 at 10:55 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Dear all, I was encountering with a typical Matching problem and was wondering whether R can help me to solve it directly. Let say, I have 2 vectors of equal length: vector1 - LETTERS[1:6] vector2 - letters[1:6] Now I need to match these 2 vectors with all possible ways like: (A,B,C,D,E) (a,b,c,d,e) is 1 match. Another match can be (A,B,C,D,E) (b,a,c,d,e), however there cant be any duplication. Is there any direct way to doing that in R? Thanks and regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] replace values in vector from a replacement table
Dear all I've got stuck when trying to replace values in a vector by selecting replacements from a replacement table. I'm trying to use only base functions. Here's a dummy example: (x - rep(letters,2)) [1] a b c d e f g h i j k l m n o p q r s t u v [23] w x y z a b c d e f g h i j k l m n o p q r [45] s t u v w x y z values - c(aa, a, b, NA, d, zz) repl - c(aa, A, B, NA, D, zz) (repl.tab - cbind(values, repl)) values repl [1,] aa aa [2,] aA [3,] bB [4,] NA NA [5,] dD [6,] zz zz Now I can easily compute all four combinations of 'match' and '%in%': (ind - match(x, repl.tab[ ,1])) [1] 2 3 NA 5 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 2 3 NA [30] 5 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA (ind - match(repl.tab[ ,1], x)) [1] NA 1 2 NA 4 NA (ind - x %in% repl.tab[ ,1]) [1] TRUE TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [15] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE [29] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [43] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE (ind - repl.tab[ ,1] %in% x) [1] FALSE TRUE TRUE FALSE TRUE FALSE But how do I actually proceed to obtain the following vector? Can it be done without an explicit apply() or loop? res [1] A B c D e f g h i j k l m n o p q r s t u v [23] w x y z A B c D e f g h i j k l m n o p q r [45] s t u v w x y z Regards Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] replace values in vector from a replacement table
try this: (x - rep(letters,2)) [1] a b c d e f g h i j k l m n o p q r s t u v w [24] x y z a b c d e f g h i j k l m n o p q r s t [47] u v w x y z values - c(aa, a, b, NA, d, zz) repl - c(aa, A, B, NA, D, zz) (repl.tab - cbind(values, repl)) values repl [1,] aa aa [2,] aA [3,] bB [4,] NA NA [5,] dD [6,] zz zz indx - match(x, repl.tab[, 1], nomatch = 0) x[indx != 0] - repl.tab[indx, 2] x [1] A B c D e f g h i j k l m n o p q r s t u v w [24] x y z A B c D e f g h i j k l m n o p q r s t [47] u v w x y z On Mon, Jul 30, 2012 at 11:53 AM, Liviu Andronic landronim...@gmail.com wrote: Dear all I've got stuck when trying to replace values in a vector by selecting replacements from a replacement table. I'm trying to use only base functions. Here's a dummy example: (x - rep(letters,2)) [1] a b c d e f g h i j k l m n o p q r s t u v [23] w x y z a b c d e f g h i j k l m n o p q r [45] s t u v w x y z values - c(aa, a, b, NA, d, zz) repl - c(aa, A, B, NA, D, zz) (repl.tab - cbind(values, repl)) values repl [1,] aa aa [2,] aA [3,] bB [4,] NA NA [5,] dD [6,] zz zz Now I can easily compute all four combinations of 'match' and '%in%': (ind - match(x, repl.tab[ ,1])) [1] 2 3 NA 5 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 2 3 NA [30] 5 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA (ind - match(repl.tab[ ,1], x)) [1] NA 1 2 NA 4 NA (ind - x %in% repl.tab[ ,1]) [1] TRUE TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [15] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE [29] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [43] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE (ind - repl.tab[ ,1] %in% x) [1] FALSE TRUE TRUE FALSE TRUE FALSE But how do I actually proceed to obtain the following vector? Can it be done without an explicit apply() or loop? res [1] A B c D e f g h i j k l m n o p q r s t u v [23] w x y z A B c D e f g h i j k l m n o p q r [45] s t u v w x y z Regards Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lattice legen and auto.key conflict
Hello R-helpers, I'm trying to customize a graphic in lattice using the 'legend' argument to add labels on my plot but in the process I'm losing the legend drawn by 'auto.key', despite the fact that I'm actually not sticking these on the same sides of the graphic. I worked up a quick and simple example with the iris data : ### here's the basic graph xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width,data=iris,groups=Species,auto.key=list(space=right)) ### now I try to add a 'legend' argument : xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width,data=iris,groups=Species,auto.key=list(space=right),legend=list(bottom=list(fun=grid.text,args=list(label=youpi ! ### and sadly the my initial legend has disappeared... Any pointers ? Many thanks in advance for your help David Gouache ARVALIS - Institut du Végétal Service Génétique Physiologie et Protection des Plantes IBP - Université Paris Sud Rue de Noetzlin - Bât. 630 91405 - ORSAY CEDEX (Adresse Postale) 91190 - GIF SUR YVETTE (Adresse GPS, livraison) Tél : +33.(0)1.69.93.85.60 Port : +33.(0)6.86.08.94.32 Fax : +33.(0)1.69.93.85.69 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to sort huge ( 2^31 row) dataframes quickly
Hello all, I have some genetic datasets (gzipped) that contain 6 columns and upwards of 10s of billions of rows. The largest dataset is about 16 GB on file, gzipped (!). I need to sort them according to columns 1, 2, and 3. The setkey() function in the data.table package does this quickly, but of course we're limited by R not being able to index vectors with 2^31 elements, and bringing in only the parts of the dataset we need is not applicable here. I'm asking for practical advice from people who've done this or who have ideas. We'd like to be able to sort the biggest datasets in hours rather than days (or weeks!). We cannot have any process take over 50 GB RAM max (we'd prefer smaller so we can parallelize). . Relational databases seem too slow, but maybe I am wrong. A quick look at the bigmemory package doesn't turn up an ability to sort like this, but again, maybe I'm wrong. My computer programmer writes in C++, so if you have ideas in C++, that works too. Any help would be much appreciated... Thanks! Matt -- Matthew C Keller Asst. Professor of Psychology University of Colorado at Boulder www.matthewckeller.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram
I have the following codes: Now, suppose I have x = runif(1000,0,1, rep(1, 250), rep(0, 100) and I want to create a 'bin' for the 0's and the 1's and put the rest of the values in say about 20 bins. How can this be done? Jim On Thu, Jul 5, 2012 at 4:08 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Which gives Jim two ways to arrive at exactly the same result, just different means of specifying the probs for quantile(). Sarah On Thu, Jul 5, 2012 at 4:01 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, With the confusion between bin size and width the OP started, I'll repost my answer with a final line. Sorry for the repetition. h - hist(x, breaks=quantile(x, probs=seq(0, 1, by=1/20))) h$counts [1] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 Hope this helps, Rui Barradas Em 05-07-2012 20:47, Sarah Goslee escreveu: There's no reason you can't do that with normally-distributed data, though I'm not sure why you'd want to. My point was rather that you can't specify the bin width and size both. If you let the bin size vary, this will work: set.seed(1234) mydata - rnorm(1000, mean = 2, sd = 4) mydata.hist - hist(mydata, breaks=quantile(mydata, probs=seq(0, 1, length.out = length(mydata)/50 + 1))) mydata.hist$counts Sarah On Thu, Jul 5, 2012 at 3:37 PM, Jim Silverton jim.silver...@gmail.com wrote: Thanks Sarah!! Ok so if I have say x = runif(1000,0,1) say instead if the normal and I want a histogram with bins that have an equal number of observations. For example if I want each bin to have 50 observations, how do I do this? On Thu, Jul 5, 2012 at 3:34 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Jim, You can't specify both number of bins and bin size. You can specify breaks: either the number of bins or the location of breakpoints. A histogram with 20 bins of 50 observations each must by definition come from a uniform distribution. What are you trying to accomplish? Sarah On Thu, Jul 5, 2012 at 3:29 PM, Jim Silverton jim.silver...@gmail.com wrote: I have a column of 1000 datapoints from the normal distribution with mean 2 and variance 4. How can I get a histogram of these observations with 20 bins with each bin having 50 observations? -- Thanks, Jim. -- Thanks, Jim. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] replace values in vector from a replacement table
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman jholt...@gmail.com wrote: try this: indx - match(x, repl.tab[, 1], nomatch = 0) x[indx != 0] - repl.tab[indx, 2] x [1] A B c D e f g h i j k l m n o p q r s t u v w [24] x y z A B c D e f g h i j k l m n o p q r s t [47] u v w x y z This is excellent! Thank you Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to sort huge ( 2^31 row) dataframes quickly
This is where the sort/merge application on the mainframe has excelled for the last 40 years. If you can not send it to a mainframe, you can look at the SyncSort package that runs on UNIX machines. On Mon, Jul 30, 2012 at 12:25 PM, Matthew Keller mckellerc...@gmail.com wrote: Hello all, I have some genetic datasets (gzipped) that contain 6 columns and upwards of 10s of billions of rows. The largest dataset is about 16 GB on file, gzipped (!). I need to sort them according to columns 1, 2, and 3. The setkey() function in the data.table package does this quickly, but of course we're limited by R not being able to index vectors with 2^31 elements, and bringing in only the parts of the dataset we need is not applicable here. I'm asking for practical advice from people who've done this or who have ideas. We'd like to be able to sort the biggest datasets in hours rather than days (or weeks!). We cannot have any process take over 50 GB RAM max (we'd prefer smaller so we can parallelize). . Relational databases seem too slow, but maybe I am wrong. A quick look at the bigmemory package doesn't turn up an ability to sort like this, but again, maybe I'm wrong. My computer programmer writes in C++, so if you have ideas in C++, that works too. Any help would be much appreciated... Thanks! Matt -- Matthew C Keller Asst. Professor of Psychology University of Colorado at Boulder www.matthewckeller.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use R to read/print the system hardware configuration
On Jul 30, 2012, at 8:42 AM, Jie wrote: Sorry to miss the OS information. I run it on Window 7 32 bit, 64 bit and Unix (version unclear, it is a grid machine.) Have you looked at: ?.Machine -- David. Best wishes, Jie On Mon, Jul 30, 2012 at 11:39 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On 30/07/2012 16:08, Jie wrote: Dear All, I am curious if there is any why to use R to know the specification of the machine that runs on, i.e. read the cpu model, memory size, those hardware info, maybe even with thesoftware information. Thank you for your attention. There are ways ... however, there are no remotely portable ways and you have not even told us your OS (as asked for in the posting guide). This sort of thing depends not just on the OS but the precise version of the OS. Look at paralllel::detectCores() for how hard one has to work to get the number of processors. Best wishes, Jie [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~**ripley/ http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] distance matrix and hclustering
For basic hierarchical clustering use groups - hclust(dist(qmu)) But there are many options for function dist() and for function hclust() and these will affect the results. For basic plotting use plot(groups) But as you will see, there are too many cases for the labels to be legible. Hierarchical clustering gives you from 1 to ncases groups. You have to decide where to cut the dendrogram to define a particular number of clusters. Since you are clustering on a single value, you may find kmeans clustering to be more useful You must specify the number of groups in advance, but you can try several group sizes to see what makes the most sense for your data. -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of eliza botto Sent: Monday, July 30, 2012 1:44 AM To: r-help@r-project.org; smartpink...@yahoo.com Subject: [R] distance matrix and hclustering Dear R Users,i am very new to R. I want your help on an issue regarding distance matrix and cluster analysis i had discharge data of 4 rivers(a,b,c,d) in 4 vectors each having 364 values dput(qmu)structure(list(a = c(0.26, 0.25, 0.25, 0.25, 0.24, 0.23, 0.22, 0.21, 0.21, 0.21, 0.2, 0.19, 0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.18, 0.19, 0.19, 0.19, 0.2, 0.21, 0.21, 0.21, 0.21, 0.21, 0.21, 0.19, 0.19, 0.18, 0.17, 0.17, 0.15, 0.18, 0.2, 0.21, 0.2, 0.19, 0.19, 0.19, 0.2, 0.24, 0.3, 0.3, 0.3, 0.32, 0.34, 0.42, 0.46, 0.48, 0.67, 0.82, 0.79, 0.73, 0.69, 0.67, 0.67, 0.66, 0.64, 0.61, 0.58, 0.56, 0.55, 0.55, 0.55, 0.52, 0.49, 0.48, 0.51, 0.53, 0.52, 0.49, 0.48, 0.48, 0.46, 0.46, 0.44, 0.43, 0.43, 0.41, 0.48, 0.55, 0.57, 0.55, 0.56, 0.6, 0.64, 0.67, 0.73, 0.84, 0.94, 1.09, 1.24, 1.28, 1.19, 1.11, 1, 0.92, 0.86, 0.79, 0.76, 0.76, 0.76, 0.76, 0.92, 0.98, 1.03, 1.03, 1.03, 1.03, 1.07, 1.11, 1.24, 1.44, 2.12, 3.26, 15, 9.45, 5.07, 4.59, 3.5, 2.84, 2.54, 2.57, 3.01, 2.32, 2.32, 2.97, 2.92, 3.88, 4.76, 5.99, 3.74, 2.92, 2.65, 2.57, 2.97, 3.4, 4.13, 4.31, 3.89, 3.45, 3.01, 2.88, 2! .5, 2.29, 2.39, 2.25, 2.02, 1.87, 1.87, 2.54, 2.69, 2.76, 3.18, 3.74, 4.59, 4.76, 4.36, 6.56, 5.07, 3.84, 3.55, 3.84, 3.84, 5.49, 5.32, 3.74, 3.31, 3.4, 3.26, 3.09, 2.69, 2.54, 2.46, 2.39, 2.25, 2.22, 2.22, 2.25, 2.29, 2.22, 2.18, 2.05, 2.18, 2.39, 2.18, 2.29, 2.11, 1.81, 1.6, 1.44, 1.41, 1.32, 1.37, 1.37, 1.65, 2.31, 2.25, 1.68, 1.41, 1.26, 1.15, 3.28, 1.93, 1.6, 1.53, 1.28, 1.13, 1.03, 1.03, 1.03, 1.03, 1, 0.96, 0.92, 0.87, 0.82, 0.79, 0.76, 0.73, 0.7, 0.67, 0.64, 0.64, 0.61, 0.61, 0.61, 1.76, 1.19, 1.24, 1.37, 1.68, 2.39, 2.05, 1.78, 1.58, 1.41, 1.39, 1.5, 1.41, 1.32, 1.19, 1.11, 1.02, 1.07, 4.57, 1.96, 1.68, 1.5, 1.37, 1.24, 1.11, 1.03, 0.96, 0.94, 2.93, 2.88, 2.92, 2.76, 2.02, 1.71, 1.5, 1.37, 1.22, 1.09, 1, 0.94, 0.87, 0.81, 0.76, 0.73, 0.7, 0.67, 0.61, 0.58, 0.57, 0.55, 0.53, 0.51, 0.48, 0.47, 0.44, 0.43, 0.43, 0.41, 0.41, 0.38, 0.4, 0.4, 0.42, 0.42, 0.41, 0.46, 0.53, 0.55, 0.52, 0.49, 0.51, 0.53, 0.55, 0.7, 1.03, 1.03, 1.17, 1.24, 1.19, 1.11, 1.03, 0.98, 0.92, 0.84,! 0.79, 0.75, 0.7, 0.67, 0.61, 0.58, 0.56, 0.56, 0.55, 0.53, 0.51, 0.48 , 0.46, 0.43, 0.41, 0.38, 0.37, 0.35, 0.34, 0.32, 0.31, 0.3, 0.29, 0.28, 0.27, 0.25, 0.26, 0.24, 0.23, 0.22, 0.22, 0.21, 0.21, 0.21), b = c(0.19, 0.19, 0.19, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 0.17, 0.16, 0.17, 0.17, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.16, 0.16, 0.17, 0.17, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.19, 0.21, 0.21, 0.21, 0.22, 0.23, 0.24, 0.24, 0.23, 0.24, 0.24, 0.25, 0.25, 0.25, 0.28, 0.29, 0.29, 0.3, 0.31, 0.31, 0.34, 0.41, 0.46, 0.51, 0.57, 0.61, 0.64, 0.67, 0.7, 0.76, 0.82, 0.86, 1.05, 1.24, 1.05, 0.94, 0.92, 0.9, 0.86, 0.82, 0.76, 0.76, 0.76, 0.78, 0.82, 0.9, 1.07, 1.76, 3.13, 3.64, 3.45, 3.01, 2.39, 2.02, 1.87, 2.11, 2.02, 1.78, 1.63, 1.53, 1.63, 4.84, 12.5, 8.11, 3.89, 2.73, 2.11, 1.96, 3.17, 2.65, 2.54, 3.01, 3.31, 3.6, 3.36, 2.76, 2.39, 2.11, 2.! 25, 2.08, 1.99, 2.11, 2.36, 3.13, 7.16, 5.39, 5.52, 5.32, 4.25, 3.45, 3.26, 3.18, 3.74, 4.35, 5.79, 5.45, 4.42, 3.84, 3.36, 2.84, 2.39, 3.84, 3.18, 3.22, 2.97, 2.73, 2.65, 2.92, 4.33, 3.01, 3.01, 3.26, 3.09, 3.6, 3.64, 4.05, 4.25, 4.48, 3.69, 3.74, 3.6, 3.18, 2.76, 4.11, 2.92, 2.69, 2.73, 2.69, 3.93, 2.69, 2.18, 2.52, 2.69, 1.99, 2.57, 1.81, 1.55, 1.44, 1.37, 1.28, 1.19, 1.19, 1.03, 1.03, 1, 0.94, 0.89, 0.87, 0.86, 0.86, 2.3, 1.55, 1.19, 1.11, 1.5, 1.39, 1.22, 1.24, 1.07, 1.02, 0.96, 0.92, 1.34, 1.15, 1.03, 2.06, 1.76, 1.3, 1.15, 1.05, 0.98, 0.92, 0.89, 0.84, 0.81, 0.76, 0.73, 1.59, 5.2, 3.01, 2.05, 1.65, 1.68, 5.29,
Re: [R] lattice legen and auto.key conflict
David: I think one needs to carefully parse the xyplot help, where it says: To use more than one legend, or to have arbitrary legends not constrained by the structure imposed by key, use the legend argument. So I presume that this is to be interpreted as: ONLY the legend argument will be used when both key(including auto.key) and legend arguments are given. However, this is not clear to me either. The Help appears to leave the behavior when one tries to use both unspecified. -- Bert On Mon, Jul 30, 2012 at 9:10 AM, GOUACHE David d.goua...@arvalisinstitutduvegetal.fr wrote: Hello R-helpers, I'm trying to customize a graphic in lattice using the 'legend' argument to add labels on my plot but in the process I'm losing the legend drawn by 'auto.key', despite the fact that I'm actually not sticking these on the same sides of the graphic. I worked up a quick and simple example with the iris data : ### here's the basic graph xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width,data=iris,groups=Species,auto.key=list(space=right)) ### now I try to add a 'legend' argument : xyplot(Sepal.Length+Sepal.Width~Petal.Length+Petal.Width,data=iris,groups=Species,auto.key=list(space=right),legend=list(bottom=list(fun=grid.text,args=list(label=youpi ! ### and sadly the my initial legend has disappeared... Any pointers ? Many thanks in advance for your help David Gouache ARVALIS - Institut du Végétal Service Génétique Physiologie et Protection des Plantes IBP - Université Paris Sud Rue de Noetzlin - Bât. 630 91405 - ORSAY CEDEX (Adresse Postale) 91190 - GIF SUR YVETTE (Adresse GPS, livraison) Tél : +33.(0)1.69.93.85.60 Port : +33.(0)6.86.08.94.32 Fax : +33.(0)1.69.93.85.69 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Possible bug in class 'POSIXlt' when including microseconds?
Dear list, I'm a bit puzzled by an ambiguity with respect to the representation of micro-/milliseconds when using 'POSIXlt' objects. It seems that the last digit of the 'sec' attribute sometimes seems to differ from the digits shown when printing the 'POSIXlt' object. You'll find a little SO post with some example code here: http://stackoverflow.com/questions/11725517/ambiguity-with-posixlt-representation-when-microseconds-are-included. In case you don't want to have a look at that, here's another short example: |opts- options(digits.secs=6) x- 2012-07-30 12:10:09.123123 posix- as.POSIXlt(x, tz=Europe/Berlin) posix [1] 2012-07-30 12:10:09.123122 Europe/Berlin posix$sec [1] 9.123123 | # Manually changing the 'sec' attribute |posix$sec- 9.123122 posix [1] 2012-07-30 12:10:09.123122 Europe/Berlin # Still '.123122' posix$sec- 9.123124 posix [1] 2012-07-30 12:10:09.123124 Europe/Berlin # Now it's '.123124' in both 'representations' | Thanks a lot for any clarification on this! Janko [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cannot install RSTAR, MSVAR, and MSVECM packages
On 30.07.2012 11:42, peter dalgaard wrote: On Jul 30, 2012, at 11:08 , Ario Ario wrote: *Hi all, I got problems installing RSTAR, MSVAR, and MSVECM packages. * No such thing exists on CRAN (nor its Archive section), so little wonder. Similarly named packages exist for the Ox matrix language, though. Such packages, however, do not readily convert themselves for use with R. ... or they have different names or have been removed from CRAN, see e.g.: http://cran.r-project.org/web/packages/STAR/index.html http://cran.r-project.org/web/packages/MSVAR/index.html Best, Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Possible bug in class 'POSIXlt' when including microseconds?
FAQ 7.31 In floating point, you get about 15 digits of precision. If you look at the value of time for today you will see: 1343668783 If you add 5 more digits after the decimal point, you will see that there is not resolution to a microsecond level. I usually assume that I can get millisecond resolution from POSIXct values. On Mon, Jul 30, 2012 at 12:52 PM, Janko Thyson janko.thyson.rst...@googlemail.com wrote: Dear list, I'm a bit puzzled by an ambiguity with respect to the representation of micro-/milliseconds when using 'POSIXlt' objects. It seems that the last digit of the 'sec' attribute sometimes seems to differ from the digits shown when printing the 'POSIXlt' object. You'll find a little SO post with some example code here: http://stackoverflow.com/questions/11725517/ambiguity-with-posixlt-representation-when-microseconds-are-included. In case you don't want to have a look at that, here's another short example: |opts- options(digits.secs=6) x- 2012-07-30 12:10:09.123123 posix- as.POSIXlt(x, tz=Europe/Berlin) posix [1] 2012-07-30 12:10:09.123122 Europe/Berlin posix$sec [1] 9.123123 | # Manually changing the 'sec' attribute |posix$sec- 9.123122 posix [1] 2012-07-30 12:10:09.123122 Europe/Berlin # Still '.123122' posix$sec- 9.123124 posix [1] 2012-07-30 12:10:09.123124 Europe/Berlin # Now it's '.123124' in both 'representations' | Thanks a lot for any clarification on this! Janko [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Z score in gplots
On Jul 29, 2012, at 9:49 PM, Khush gg wrote: Hi, Can anyone tell me how to set Z-score according to my own requirement as the below code is taking as per the file entries. Any help would be appreciable. That was a bit vague and hard to parse, but I'm thinking I may need to make allowance for a non-native speaker. The help page for heatmap.2 has an example that demonstrates changing the color palette to 'bluered'. If you run that that example and then look at the output, you should see that the 'breaks' value is returned and is on a Z-scale as a result of setting the scale argument ... as you may already understand. Since there is also a breaks argument, that would appear to be the setting you should be modifying. library(gplots) x=read.table(final.txt, header=TRUE) However, ... you have not provided a reproducible example, and that is not something I make much allowance for: x=read.table(final.txt, header=TRUE) Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file 'final.txt': No such file or directory So I cannot offer a tested example. If you need further commentary perhaps you could use the help page examples as a starting point for further discussion rather than offering code that will surely fail. snipped code. Thank you in advance KS [[alternative HTML version deleted]] Please do not ignore the boilerplate message: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- David. David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How can I use IPF function correctly?
Im not sure what SAS is doing (or if you are using it correctly). In R you do not create marginal totals independent of the data and try to fit them to the data. In your first example you create a matrix called raw, but you do not use it for anything. Your loglin() call is for the all cells 16.67 and then you fit a model in which the row and column marginal totals are used but not the row*column marginal. Im not really sure what you are trying to accomplish with that. In your second example you create three variables and then want to fit another set of marginal totals that seem to be roughly equal distribution for rows/columns/pages except that race has four categories but tart.reg has only three??? If the null hypothesis for these data is no interaction between the variables and that each category should have the same proportion of cases: age=c(1/3, 1/3, 1/3), gender=c(1/2, 1/2), race=c(1/4, 1/4, 1/4, 1/4), then try this: mytable - xtabs(~age+gender+race, rawdat) # table() loses the variable names loglin(mytable, margin=list(0), fit=TRUE) If you want to preserve the marginal totals for each variable, but not any interactions between them use loglin(mytable, margin=list(1, 2, 3), fit=TRUE) If you want to fit the three two-way interactions use loglin(mytable, margin=list(c(1, 2), c(2, 3), c(1, 3)), fit=TRUE) If you want to fit the saturated table (all interactions), use loglin(mytable, margin=list(c(1, 2, 3)), fit=TRUE) --- David From: Miao Zhang [mailto:mandyzhangpub...@gmail.com] Sent: Monday, July 30, 2012 9:35 AM To: dcarl...@tamu.edu Subject: Re: [R] How can I use IPF function correctly? Thanks David, The purpose of doing this is that i am trying to weighted the data to get the target values (yes, I am using percentage instead of counts here), I could get what I need for 2 way tables as using loglin() codes as below, I have the row target and column target value: raw-matrix(c(28.571,14.286,23.809,4.762,9.523,19.049),3,2,byrow=TRUE) rowmarg-c(33.4,33.3,33.3) colmarg-c(50,50) newmat1 - loglin( rowmarg%o%colmarg/sum(colmarg), margin=list(1,2), start=raw, fit=TRUE, eps=1.e-05, iter=100)$fit Am I am not sure how to expending into 3 or higher dimensions(I need expending into higher dimentions latter), that's why I am considering Iterative proportional fitting/ipf(), SAS can use ipf call, but i am not sure how to apply in R, here we could use counts instead of %, here is an example, say we have age, gender and region 3 variables, by using frequency: ### set a rawdata and view the frequency age - c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,1,1,2,1,2,2,2,3,3,3,3,1,1, 1,1,2,2,2,2,2,2,2,2,3,3,3,3) gender - c(1,1,1,1,2,2,2,2,1,1,1,1,2,2,2,2,1,1,1,1,2,2,2,2,1,1,2,2,2,2,2,1,1,1,1,2,2, 2,2,1,1,1,1,2,2,2,2,1,1,1,1) race - c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,2,2,2,3,4,1,2,3,4,1,2, 3,4,1,2,3,4,1,2,3,4,1,2,3,4) rawdat-data.frame (age,gender,race) View (rawdat) mytable - table (rawdat$age,rawdat$gender,rawdat$race) #generates a cross-tab of counts View (mytable) ### set target value to weight the frequency 3 dimensions, NOTE, we are using counts here not percentage, trying to fit the frequency to the target value targ.age-c(17,17,17) targ.gen-c(24,26) targ.reg-c(13,13,12) f2-ipf(mytable, margins=c(1,2,0,1,3,0,2,3), eps = 1e-04, maxits = 50, showits = TRUE) #no 3 way interaction Where and how should I input/set my target value here? Any sugguestions? or I have to write my own function? Manythanks, Mandy On Fri, Jul 27, 2012 at 5:11 PM, David L Carlson dcarl...@tamu.edu wrote: It is not clear what you are trying to do. The ipf() function you are using seems to be the one included in package cat for imputing missing values for categorical variables. For ipf() you have not read the instructions carefully because you have entered the marginal values, not their dimensions and you have given ipf() a 2 way table but miss-specified a three way model. No wonder it is confused. Function loglin() which is part of the included stats package also does iterative proportional fitting. Iterative proportional fitting (ipf) is used for fitting models for categorical data when there are three or more variables. There is no need for ipf on a table with two variables since, the values can be directly calculated. Your example data does not include the raw data counts (as it should), but percentages for each of the 3 x 2 cells (I assume, since they sum to 100). The marginal values you list (again percentages) are for a model assuming equal margins. That is easily computed as 1/3*1/2*100 (one third in each row by one half in each column times 100). So each cell should be 16.667 percent of the total. Using loglin() that would be specified as follows: loglin(raw, margin=list(0), fit=TRUE) 0 iterations: deviation $lrt [1] 25.87661 $pearson [1] 23.80933 $df [1] 5 $margin [1] 0 $fit [,1] [,2] [1,] 16.7 16.7 [2,] 16.7 16.7 [3,]
Re: [R] Hmisc improveProb() and PredictABEL reclassification () function and continuous NRI
If you type improveProb at the command line you'll see all the code, which is quite simple. I'm glad you are not attempting to classify risk as this is almost always futile. Frank Svingen, Gard Frodahl wrote Dear Sirs. I am working with the R packages Hmisc and PredictABEL to make NRI estimates from my Cox models with and without a specific biomarker. According to Pencina et al (Statistics in Medicine 2010, DOI: 0.1002/sim.4085 ), a continuous/non-categorical NRI (NRI0) is to be used when there are no obvious reason to categorize risk, such as the risk of future cardiovascular events in patients with established cardiovascular disease. My question is therefore: Which value(s) are to be used in the calculation of continuous NRI from the output in Hmisc or in PredictABEL? Does continuous NRI equal total NRI in the output? Yours sincerely Gard Frodahl T. Svingen PhD student the University of Bergen Bergen, Norway [[alternative HTML version deleted]] __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Hmisc-improveProb-and-PredictABEL-reclassification-function-and-continuous-NRI-tp4630259p4638347.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] length of variable in mlogit
Dear all, does anybody have experience with building logits in Mlogit? I want to test the use of a couple of alternative specific variables with a generic regression coefficient. However, one of them simply does not work. R says the length of this variable is different. Problem: If I check the length of this special variable, I get a value, which also other variables have – and with those, the logit model works! I also checked the class of the explaining variables. The problem-laden variable is a matrix – but the model is working with other variables which are of the matrix and the data frame class. I also see no problems because of wide/long formats. Does anybody happen to know what else I can check? Any help would be much appreciated. Best regards! -- View this message in context: http://r.789695.n4.nabble.com/length-of-variable-in-mlogit-tp4638323.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cell blocking in log-linear models with a survey sample
Hello. I hope someone can suggest a way to test log-linear models with cells blocked when working with survey data. The tables I am working with come from a multi-stage stratified sample. The command 'svyloglin' in the package 'survey' works well when I want to choose between models with two or three-way effects, but I haven't been able to figure out how to get proper p-values to compare models with and without blocked cells. Thanks in advance for any suggestions. Bob Arnold [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Marginal effects in mlogit
Dear all, does anybody have experience with the calculation of marginal effects (“effects”) in Mlogit (see Croissant, Package ‘mlogit’, p.8)? 1) Is there a good qualitative explanation available for the listed options for the argument “type” (“aa”, …)? When do I have to choose aa, ar…? And when can I leave it out? 2) The table in the output – how is it to read? Does it refer to relative changes (percentage) in the probability or absolute values (percentage points)? Any help including hints for literature is welcome. Best regards! -- View this message in context: http://r.789695.n4.nabble.com/Marginal-effects-in-mlogit-tp4638322.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pairwise comparisons in accordance with regression fit
Hello, I have a unconventional question arising from my current master thesis on regression modeling. Suppose we have fitted a (linear) relationship between a dependent variable y and an independent variable x. Now we choose two points on the x-axis, i.e. according to percentiles x10 and x90. These two points are chosen to select the data points for two groups in order to perform pairwise comparisons. In the first run, we choose 20 data pairs around the x-values of x10 and x90 and run a statistical test in order to infere if their y-values differ significantly. In a subsequent step, we choose, say 30 data points around x90 and test against x10; in the next step 40 data points around x90 and test against x10 and so on. The intention for this is to determine the group size and consequently the corresponding lowest x-value where the comparison turns out to be significant. How would you approach this problem. I thought of a many-to-one procedure like the Dunnett test where multiple groups are tested against the same control (which could be x10 in our example) (package multcomp or others). However, these multiple groups would contain partly the same subjects. Or is some sort of adaptive design the right choice. Or something completely different? I'd be very happy for any kind of help since I'm completely stuck with this question and have no idea how to solve it Kind regards Andres -- View this message in context: http://r.789695.n4.nabble.com/pairwise-comparisons-in-accordance-with-regression-fit-tp4638328.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with Bootres dcc and Dendroclim match
Dear all, I hope someone can assist with soliving my problems with the DCC function in the BOOTRES package. Initially did my analyses in Dendroclim, but when I tried to repeat the analyses in dcc I encountered some problems, that I think I should report. First I encountered that that one variable (April precipitation) that was determined as significant in Dendroclim's response function analysis was not significant when using the corresponding dcc function, using exactly the same data and level of significans. Moreover the values in the output-files of dcc does not reflect completely the values from Dendroclim (with all decimals). While Dendroclim returns exactly the same values each time the same analysis is run, dcc values seem to change a bit each time. This seems a bit odd, but I do not know the analysis good enough to say it is wrong. After more testing I found out that 'April precipitation' is significant first time I run the dcc analysis after starting R, but in all succeeding runs, the variable is claimed NS. And this despite the confidence intervals do not always include the zero value in each run, (which according to my knowledge is the way the significant variables are determined). One last question: I would like to know if values from correlation analysis or response function analysis fits the data best. Is there a way to to obtain a value for model performance from dcc like e.g. a AIC value? I use : R version 2.15.1 (2012-06-22) -- Roasted Marshmallows, Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0, Platform: i386-pc-mingw32/i386 (32-bit). For Windows XP. But I also encountered the same problems in R version 2.15.0. My script: response - dcc(kronologiprewhite, list(temp,precip), method = response, start = -6, end = 7, timespan=c(1963,2008), ci = 0.05, boot=TRUE) I very much hope someone can find the time to answer my questions. Rasmus Halfdan Jørgensen -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-Bootres-dcc-and-Dendroclim-match-tp4638327.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] barplot question
Dear r-help members. I would like to: a) control the margin around my legend box. Unfortunately I did not find an appropriate command under ?legend. The margin around the actual legend is way too wide. There is a lot of unnecessary empty space on the right side. b) increase the width of the individual barplots. I saw that this can be obtained with the command width and xlim.However, since I have 3 Barplots next to each other beside=T, I could not figure it out how to do it (2 Barplots are disappearing) c) I wanted to label each bar (names.arg) unfortunately nothing happens if I use this command (in my code i just used 1:10 for the names, in the original plot I would replace the numbers with real names) Thank you very much: Input data (dput) structure(list(total = c(28L, 17L, 11L, 6L, 6L, 5L, 4L, 3L, 3L, 2L), young = c(29L, 22L, 15L, 8L, 5L, 3L, 2L, 2L, 2L, 2L), old = c(36L, 11L, 11L, 8L, 6L, 5L, 4L, 3L, 2L, 2L)), .Names = c(total, young, old), class = data.frame, row.names = c(NA, -10L)) R-code: barplot(as.matrix(plants_herbs_input_top10),xaxt=n, space=c(0.5,12),ylab= Relative frequencies (%),beside=TRUE, col=c(rep(black,10),rep(chartreuse1,10),rep(chartreuse4,10)),ylim=c(0,50),cex.names=0.8,names.arg=c(1, 2, 3,4,5,6,7,8,9,10,1, 2, 3,4,5,6,7,8,9,10,1, 2, 3,4,5,6,7,8,9,10)) legend(topright,c(Total,Young secondary forest,Old secondary forest),cex=0.9,pt.cex=1,y.intersp=0.4,pch=15,col=c(black,chartreuse1,chartreuse4)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem creation tensor
Hi, thank Petr for your help. I have implemented you code suggestion but there is another problem. It seems that the code: for (i in 1:m){ Z[i,,]=table(occ, data_matrix[,i]) } don't charge any values in Z. Is there some error? Thanks. Giuseppe -- View this message in context: http://r.789695.n4.nabble.com/Problem-creation-tensor-tp4636737p4638333.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MANOVA polynomial contrasts
Dear Prof. John Fox, thus all I should do to test quadratic and cubic effects is to change the second argument of the linearHypothesis() function, right? So, for testing the cubic effect: linearHypothesis (mod, f.C) Is there a chapter or paragragh about contrasts in your book An R companion for applied regression? Best regards, GMM 2012/7/30 John Fox j...@mcmaster.ca Dear Gian Mauro, On Mon, 30 Jul 2012 14:44:44 +0200 Manzoni, GianMauro gm.manz...@auxologico.it wrote: Dear Prof. John Fox, thank you very much for your suggestions. However, I still do not know how to use the contrasts after generating them. Once I generate the matrix with the polynomial contrasts, what are the following steps toward the statistical test? Here's a contrived example, which uses the Anova() and linearHypothesis() functions in the car package: - snip -- Y - matrix(rnorm(300), 100, 3) colnames(Y) - c(y1, y2, y3) f - ordered(sample(letters[1:4], 100, replace=TRUE)) (mod - lm(Y ~ f)) Call: lm(formula = Y ~ f) Coefficients: y1y2y3 (Intercept) 0.06514 -0.01683 -0.13787 f.L -0.37837 0.18309 0.29736 f.Q -0.02102 -0.39894 0.08455 f.C 0.05898 0.09358 -0.17634 Anova(mod) Type II MANOVA Tests: Pillai test statistic Df test stat approx F num Df den Df Pr(F) f 3 0.11395 1.2634 9288 0.2566 linearHypothesis(mod, f.L) Sum of squares and products for the hypothesis: y1y2y3 y1 3.607260 -1.745560 -2.834953 y2 -1.745560 0.844680 1.371839 y3 -2.834953 1.371839 2.227995 Sum of squares and products for error: y1y2y3 y1 86.343376 -8.054928 -3.711756 y2 -8.054928 95.473020 2.429151 y3 -3.711756 2.429151 89.593163 Multivariate Tests: Df test stat approx F num Df den Df Pr(F) Pillai1 0.0648520 2.172951 3 94 0.096362 . Wilks 1 0.9351480 2.172951 3 94 0.096362 . Hotelling-Lawley 1 0.0693495 2.172951 3 94 0.096362 . Roy 1 0.0693495 2.172951 3 94 0.096362 . --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 - snip -- You could do similar tests for the quadratic and cubic contrasts. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ A whole example would be very useful. Thank you very much in advance! Best regards, Gian Mauro Manzoni 2012/7/25 John Fox j...@mcmaster.ca Dear Gian, How contrasts are created by default is controlled by the contrasts option: getOption(contrasts) unordered ordered contr.treatment contr.poly So, unless you've changed this option, contr.poly() will be used to generate orthogonal polynomial contrasts for an ordered factor, and you therefore need do nothing special to get this result. For example: (f - ordered(sample(letters[1:3], 10, replace=TRUE))) [1] c c a a c c b c a c Levels: a b c round(contrasts(f), 4) .L .Q [1,] -0.7071 0.4082 [2,] 0. -0.8165 [3,] 0.7071 0.4082 For more information, see section 11 on statistical models in the manual An Introduction to R, which is part of the standard R distribution, and in particular sections 11.1 and 11.1.1. I hope that this clarifies the issue. Best, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 25 Jul 2012 11:58:30 +0200 Manzoni, GianMauro gm.manz...@auxologico.it wrote: Dear Greg Snow, thank you very much for your suggestions. However, I need an example in order to understand fully. I was told that, given the ordinal factor, I do not need to specify the contr.poly function because R does it automatically. However, I don not know if I have to add an argument into the manova/anova function or something else. Please write me an illustrative example. Many thanks. Best regards, Gian Mauro Manzoni 2012/7/25 Greg Snow 538...@gmail.com You should not need to write them yourself. Look at the contr.poly function along with the C function (Note uppercase C) or the contrasts function. On Monday, July 23, 2012, Manzoni, GianMauro wrote: Dear all, I am quite new to R and I am having trouble writing the polynomial contrasts for an ordinal factor in MANOVA. # I have a model such as this fit-manova(cbind(Y1,Y2,Y3)~Groups,data=Events) # where groups is an ordinal
Re: [R] Convert variable to STring
Hello, Not sure whether this is what you need. colnames(mymatrix)-c(function1,function2,function3) toString(colnames(mymatrix)) #[1] function1, function2, function3 A.K. - Original Message - From: Alaios ala...@yahoo.com To: R help R-help@r-project.org Cc: Sent: Monday, July 30, 2012 6:47 AM Subject: [R] Convert variable to STring Dear all, I have a variable that I would like also to use it as a string. The reasons is that I want to collect results from different function to one table.. So when I use the colnames(mymatrix) -c(function1.function2,function3) the function1, function2, function3 to be converted to simple strings so as colnames(mymatrix) -c(function1,function2,function3) Could you please help me understand how I can do that in R? Regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MANOVA polynomial contrasts
Dear GMM, -Original Message- From: Manzoni, GianMauro [mailto:gm.manz...@auxologico.it] Sent: July-30-12 9:49 AM To: John Fox Cc: r-help@r-project.org; Greg Snow Subject: Re: [R] MANOVA polynomial contrasts Dear Prof. John Fox, thus all I should do to test quadratic and cubic effects is to change the second argument of the linearHypothesis() function, right? So, for testing the cubic effect: linearHypothesis (mod, f.C) Yes, but wouldn't it have been faster simply to try it? Also see ?linearHypothesis. Is there a chapter or paragragh about contrasts in your book An R companion for applied regression? There are discussions of contrasts and of linear hypotheses about coefficients, though not in the context of *multivariate* linear models; that's the subject of an on-line appendix, at http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix/Appendix-Mul tivariate-Linear-Models.pdf. Best, John Best regards, GMM 2012/7/30 John Fox j...@mcmaster.ca Dear Gian Mauro, On Mon, 30 Jul 2012 14:44:44 +0200 Manzoni, GianMauro gm.manz...@auxologico.it wrote: Dear Prof. John Fox, thank you very much for your suggestions. However, I still do not know how to use the contrasts after generating them. Once I generate the matrix with the polynomial contrasts, what are the following steps toward the statistical test? Here's a contrived example, which uses the Anova() and linearHypothesis() functions in the car package: - snip -- Y - matrix(rnorm(300), 100, 3) colnames(Y) - c(y1, y2, y3) f - ordered(sample(letters[1:4], 100, replace=TRUE)) (mod - lm(Y ~ f)) Call: lm(formula = Y ~ f) Coefficients: y1y2y3 (Intercept) 0.06514 -0.01683 -0.13787 f.L -0.37837 0.18309 0.29736 f.Q -0.02102 -0.39894 0.08455 f.C 0.05898 0.09358 -0.17634 Anova(mod) Type II MANOVA Tests: Pillai test statistic Df test stat approx F num Df den Df Pr(F) f 3 0.11395 1.2634 9288 0.2566 linearHypothesis(mod, f.L) Sum of squares and products for the hypothesis: y1y2y3 y1 3.607260 -1.745560 -2.834953 y2 -1.745560 0.844680 1.371839 y3 -2.834953 1.371839 2.227995 Sum of squares and products for error: y1y2y3 y1 86.343376 -8.054928 -3.711756 y2 -8.054928 95.473020 2.429151 y3 -3.711756 2.429151 89.593163 Multivariate Tests: Df test stat approx F num Df den Df Pr(F) Pillai1 0.0648520 2.172951 3 94 0.096362 . Wilks 1 0.9351480 2.172951 3 94 0.096362 . Hotelling-Lawley 1 0.0693495 2.172951 3 94 0.096362 . Roy 1 0.0693495 2.172951 3 94 0.096362 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 - snip -- You could do similar tests for the quadratic and cubic contrasts. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ A whole example would be very useful. Thank you very much in advance! Best regards, Gian Mauro Manzoni 2012/7/25 John Fox j...@mcmaster.ca Dear Gian, How contrasts are created by default is controlled by the contrasts option: getOption(contrasts) unordered ordered contr.treatment contr.poly So, unless you've changed this option, contr.poly() will be used to generate orthogonal polynomial contrasts for an ordered factor, and you therefore need do nothing special to get this result. For example: (f - ordered(sample(letters[1:3], 10, replace=TRUE))) [1] c c a a c c b c a c Levels: a b c round(contrasts(f), 4) .L .Q [1,] -0.7071 0.4082 [2,] 0. -0.8165 [3,] 0.7071 0.4082 For more information, see section 11 on statistical models in the manual An Introduction to R, which is part of the standard R distribution, and in particular sections 11.1 and 11.1.1. I hope that this clarifies the issue. Best, John John Fox Sen. William
Re: [R] curve comparison
I'm very much a novice with R, and not a statistician. But as my group has been working with generalized additive models (semi-parametric regression), we have followed Wood's advice about using the R anova function to do model comparison for different regressions. I would imagine at least some of yours might be nested, e.g., adding polynomial functions to some? If so, model comparisons like this might be justified. Will Shadish On 7/29/2012 10:38 PM, Luis Fernando García Hernández wrote: Dear R users, I have seven regression lines I´d like to compare, in order to find out if these are significatively different. The main problem is that these are curves, non normal, non homogeneous data, I´ve tried to linearize them but it has not worked. So I´d like to know if you know any command or source in R which explains how to perform this kind of comparison. Thanks in advance for your help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- William R. Shadish Distinguished Professor Founding Faculty Chair, Psychological Sciences Mailing Address: William R. Shadish University of California School of Social Sciences, Humanities and Arts 5200 North Lake Rd Merced CA 95343 Physical/Delivery Address: University of California Merced ATTN: William Shadish School of Social Sciences, Humanities and Arts Facilities Services Building A 5200 North Lake Rd. Merced, CA 95343 209-228-4372 voice 209-228-4390 fax wshad...@ucmerced.edu http://faculty.ucmerced.edu/wshadish/index.htm http://psychology.ucmerced.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MANOVA polynomial contrasts
Dear Prof. John Fox, thank you very much for your suggestions. However, I still do not know how to use the contrasts after generating them. Once I generate the matrix with the polynomial contrasts, what are the following steps toward the statistical test? A whole example would be very useful. Thank you very much in advance! Best regards, Gian Mauro Manzoni 2012/7/25 John Fox j...@mcmaster.ca Dear Gian, How contrasts are created by default is controlled by the contrasts option: getOption(contrasts) unordered ordered contr.treatment contr.poly So, unless you've changed this option, contr.poly() will be used to generate orthogonal polynomial contrasts for an ordered factor, and you therefore need do nothing special to get this result. For example: (f - ordered(sample(letters[1:3], 10, replace=TRUE))) [1] c c a a c c b c a c Levels: a b c round(contrasts(f), 4) .L .Q [1,] -0.7071 0.4082 [2,] 0. -0.8165 [3,] 0.7071 0.4082 For more information, see section 11 on statistical models in the manual An Introduction to R, which is part of the standard R distribution, and in particular sections 11.1 and 11.1.1. I hope that this clarifies the issue. Best, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Wed, 25 Jul 2012 11:58:30 +0200 Manzoni, GianMauro gm.manz...@auxologico.it wrote: Dear Greg Snow, thank you very much for your suggestions. However, I need an example in order to understand fully. I was told that, given the ordinal factor, I do not need to specify the contr.poly function because R does it automatically. However, I don not know if I have to add an argument into the manova/anova function or something else. Please write me an illustrative example. Many thanks. Best regards, Gian Mauro Manzoni 2012/7/25 Greg Snow 538...@gmail.com You should not need to write them yourself. Look at the contr.poly function along with the C function (Note uppercase C) or the contrasts function. On Monday, July 23, 2012, Manzoni, GianMauro wrote: Dear all, I am quite new to R and I am having trouble writing the polynomial contrasts for an ordinal factor in MANOVA. # I have a model such as this fit-manova(cbind(Y1,Y2,Y3)~Groups,data=Events) # where groups is an ordinal factor with 4 levels # how to set polynomial contrasts for the Groups factor ? Thank you very much in advance for any help! Best regards, Mauro -- Dr. Gian Mauro Manzoni PhD, PsyD Psychology Research Laboratory San Giuseppe Hospital Istituto Auxologico Italiano Verbania - Italy e-mail: gm.manz...@auxologico.it cell. phone +39 338 4451207 Tel. +39 0323 514278 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com -- Dr. Gian Mauro Manzoni PhD, PsyD Psychology Research Laboratory San Giuseppe Hospital Istituto Auxologico Italiano Verbania - Italy e-mail: gm.manz...@auxologico.it cell. phone +39 338 4451207 Tel. +39 0323 514278 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. Gian Mauro Manzoni PhD, PsyD Psychology Research Laboratory San Giuseppe Hospital Istituto Auxologico Italiano Verbania - Italy e-mail: gm.manz...@auxologico.it cell. phone +39 338 4451207 Tel. +39 0323 514278 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Unable to install gsl package
I'm attempting to install the gsl package using the following command: install.packages(c:/users/mike/documents/R/win-library/gsl_1.9-9.tar.gz,repos=NULL,type=source) My attempt is failing. Please help. The message supplied is: Installing package(s) into C:/Users/Mike/Documents/R/win-library/2.15 (as lib is unspecified) * installing *source* package 'gsl' ... ** package 'gsl' successfully unpacked and MD5 sums checked ** WARNING: this package has a configure script It probably needs manual configuration ** ** libs gcc -m64 -IC:/PROGRA~1/R/R-215~1.0/include -DNDEBUG -I/include -Id:/RCompile/CRANpkg/extralibs64/local/include -O2 -Wall -std=gnu99 -mtune=core2 -c airy.c -o airy.o airy.c:1: sorry, unimplemented: 64-bit mode not compiled in airy.c:1: error: bad value (core2) for -mtune= switch C:/PROGRA~1/R/R-215~1.0/etc/x64/Makeconf:172: recipe for target `airy.o' failed make: *** [airy.o] Error 1 ERROR: compilation failed for package 'gsl' * removing 'C:/Users/Mike/Documents/R/win-library/2.15/gsl' Warning messages: 1: running command 'C:/PROGRA~1/R/R-215~1.0/bin/x64/R CMD INSTALL -l C:/Users/Mike/Documents/R/win-library/2.15 c:/users/mike/documents/R/win-library/gsl_1.9-9.tar.gz' had status 1 2: In install.packages(c:/users/mike/documents/R/win-library/gsl_1.9-9.tar.gz, : installation of package c:/users/mike/documents/R/win-library/gsl_1.9-9.tar.gz had non-zero exit status [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] multiple comparison tests using medians
Hi, A client has asked for a series of pair-wise tests similar to Tukey's but using medians as opposed to means. The reason is that the distributions are highly right skewed. Are there such tests (I'm finding nothing) and if so, is there anything in R? Thanks, Walt Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 (V) 609-936-8999 (F) 609-936-3733 w...@dataanalyticscorp.com www.dataanalyticscorp.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Optimization help
Hi, I have following optimization problem: Min: x1 + x2 +...+ x7 subject to: x1 + x2 = 80 x2 + x3 = 65 x3 + x4 = 40 all xi are ***positive integer***. Can somebody help me in this optimization problem? Thanks for your help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If equal statement for character objects
1. Please read an Intro to R before posting further. In your previous post you confused = with ==. These and other basic matters are discussed there, so you can save yourself -- and this list -- a lot of time and aggravation by familiarizing yourself with it.(Unless this was just a typo). 2. I presume that you read the ?all.equal Help -- the part about not using all.equal directly in if() expressions -- and adjusted your code accordingly? 3. Please post directly to this list, not on Nabble, as context is lost for those who access R-help directly, which means also that you reduce the likelihood of a helpful reply. -- Bert On Mon, Jul 30, 2012 at 7:41 AM, cm bunnylove...@optonline.net wrote: nevermind. all.equal() works! -- View this message in context: http://r.789695.n4.nabble.com/If-equal-statement-for-character-objects-tp4638359p4638361.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] te( ) interactions and AIC model selection with GAM
Hello R users, I'm working with a time-series of several years and to analyze it, I’m using GAM smoothers from the package mgcv. I’m constructing models where zooplankton biomass (bm) is the dependent variable and the continuous explanatory variables are: -time in Julian days (t), to creat a long-term linear trend -Julian days of the year (t_year) to create an annual cycle - Mean temperature of Winter (temp_W), Temperature of September (temp_sept) or Chla. Questions: 1) To introduce a tensor product modifying the annual cycle in my model, I tried 2 different approaches: - a) gam ( bm ~ t + te (t_year, temp_W, temp_sept, k = c( 5,30), d= ( 1,2), bs = c( “cc”,”cr”)), data = data) -b) gam ( bm ~ t + te (t_year, temp_W, temp_sept, k = 5, bs = c( “cc”,”cr”,”cr”)), data = data) Here is my problem: when I’m using just 2 variables (e.g., t_year and temp_W) for the tensor product, I can understand pretty well how the interpolation works and visualize it with vis.gam() as a 3d plot or a contour one. But with 3 variables is difficult to me to understand how it works. Besides, I don’t which one is the proper way to construct it, a) or b). Finally, when I plot a) or b) as vis.gam (model_name , view= c(“t_year”, “temp_W”)), How should I interpret the plot? The effect of temp_W on the annual cycle after considering already the effect of temp_sept or just the individual effect of Temp_W on the annual cycle? 2) I’m trying to do a model selection using AIC criteria. I have several questions about it: - Should I use always the same type of smoothing basis (bs), the same type of smoother ( e.g te) and the same dimension of the basis (k)? Example: Option 1: a) mod1 - gam (bm ~ t, data = data) b) mod2 - gam (bm ~ te (t, k = 5, bs = “cr”), data = data) c) mod3 - gam (bm ~ te (t_year, k = 5, bs = “cc”), data = data) d) mod4 - gam (bm ~ te (t_year, temp_W, k = 5, bs = c(“cc”,”cr”)), data = data) e) mod5 - gam (bm ~ te (t_year, temp_W, temp_sept, k = 5, bs = c(“cc”,”cr”,”cr”)), data = data). Here the limitation for k = 5, is due to mod5, I don’t use s () because in mod4 and mod5 te () is used and finally, I always use “cr” and “cc”. Option 2: a) mod1 - gam (bm ~ t, data = data) b) mod2 - gam (bm ~ s (t, k = 13, bs = “cr”), data = data) c) mod3 - gam (bm ~ s (t_year, k = 13, bs = “cc”), data = data) d) mod4 - gam (bm ~ te (t_year, temp_W, k = 11, bs = c(“cc”,”cr”)), data = data) e) mod5 - gam (bm ~ te (t_year, temp_W, temp_sept, k = 5, bs = c(“cc”,”cr”,”cr”)), data = data). I can get lower AIC for each of the models with Option 2, but are they comparable when I use AIC criteria? Is it therefore the proper way to do it as in Option 1? AIC (mod1, mod2, mod3, mod4, mod5). Thank you in advance, Best regards, Ricardo González-Gil -- View this message in context: http://r.789695.n4.nabble.com/te-interactions-and-AIC-model-selection-with-GAM-tp4638368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A matching problem
On Mon, Jul 30, 2012 at 08:40:59PM +0545, Christofer Bogaso wrote: Dear all, I was encountering with a typical Matching problem and was wondering whether R can help me to solve it directly. Let say, I have 2 vectors of equal length: vector1 - LETTERS[1:6] vector2 - letters[1:6] Now I need to match these 2 vectors with all possible ways like: (A,B,C,D,E) (a,b,c,d,e) is 1 match. Another match can be (A,B,C,D,E) (b,a,c,d,e), however there cant be any duplication. Hi. If i understand correctly, all matches are obtained by taking all permutations of (a,b,c,d,e) and relating them to unchanged (A,B,C,D,E). Try the following. library(permute) vector2 - letters[1:3] p - allPerms(length(vector2), observed=TRUE) matrix(vector2[p], nrow=nrow(p), ncol=ncol(p)) [,1] [,2] [,3] [1,] a b c [2,] a c b [3,] b a c [4,] b c a [5,] c a b [6,] c b a The rows of the resulting matrix are all permutations of vector2. Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Are there any package for sub-sampling data
Hi all, I need to sub sample some large data sets. The problem is using complete data samples for bats that are ± data per 1-minute time blocks using acoustic data collection and a method I published some time back. Miller, B. W. 2001. A method for determining relative activity of free flying bats using a new activity index for acoustic monitoring. Acta Chiropterologica. 3: 93-105. I am convinced after analyzing complete data for each night to derive relative abundance and species compositions that the consultants who are doing wind power monitoring and ONLY using 5 to 10 minute sub samples for each hour like the first 5 or 10 minutes are missing especially eh rare species that have only a few occurrences so misleading results. Anyone have any suggestions to a field ecologists who is not a dyed in the wool stats person on how to sub sample the data sets and robustly test this hypothesis? Happy to co-author a paper if some one is interested as I have the data. Cheers, Bruce -- Bruce W. Miller, Ph.D. Conservation Ecologist Neotropical Bat Projects office details 11384 Alpine Road Stanwood, Mi. 49346 Phone (231) 679-6059 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calculating percentiles for multiple dates
I was hoping to calculate the percentile for each date. So group all of one date together, calculating the value of the 2.5 and 97.5 percentile. -- View this message in context: http://r.789695.n4.nabble.com/Calculating-percentiles-for-multiple-dates-tp4638183p4638378.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sprintf doesn't care of escape characters
Hi. I am having trouble with something that should be simple. I am unable to get sprintf using escape sequences: sprintf(a\nb) [1] a\nb sprintf(a\bc\d) [1] a\bc\d But it seems to need them any way: sprintf(a\bcd) Error: unexpected symbol in sprintf(a\bcd Any suggestion on how to solve this issue? My R system: version _ platform x86_64-suse-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.0 year 2012 month 03 day30 svn rev58871 language R version.string R version 2.15.0 (2012-03-30) Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram
On Jul 30, 2012, at 9:29 AM, Jim Silverton wrote: I have the following codes: Now, suppose I have x = runif(1000,0,1, rep(1, 250), rep(0, 100) and I want to create a 'bin' for the 0's and the 1's and put the rest of the values in say about 20 bins. How can this be done? ?cut -- David. Jim On Thu, Jul 5, 2012 at 4:08 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Which gives Jim two ways to arrive at exactly the same result, just different means of specifying the probs for quantile(). Sarah On Thu, Jul 5, 2012 at 4:01 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, With the confusion between bin size and width the OP started, I'll repost my answer with a final line. Sorry for the repetition. h - hist(x, breaks=quantile(x, probs=seq(0, 1, by=1/20))) h$counts [1] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 Hope this helps, Rui Barradas Em 05-07-2012 20:47, Sarah Goslee escreveu: There's no reason you can't do that with normally-distributed data, though I'm not sure why you'd want to. My point was rather that you can't specify the bin width and size both. If you let the bin size vary, this will work: set.seed(1234) mydata - rnorm(1000, mean = 2, sd = 4) mydata.hist - hist(mydata, breaks=quantile(mydata, probs=seq(0, 1, length.out = length(mydata)/50 + 1))) mydata.hist$counts Sarah On Thu, Jul 5, 2012 at 3:37 PM, Jim Silverton jim.silver...@gmail.com wrote: Thanks Sarah!! Ok so if I have say x = runif(1000,0,1) say instead if the normal and I want a histogram with bins that have an equal number of observations. For example if I want each bin to have 50 observations, how do I do this? On Thu, Jul 5, 2012 at 3:34 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Jim, You can't specify both number of bins and bin size. You can specify breaks: either the number of bins or the location of breakpoints. A histogram with 20 bins of 50 observations each must by definition come from a uniform distribution. What are you trying to accomplish? Sarah On Thu, Jul 5, 2012 at 3:29 PM, Jim Silverton jim.silver...@gmail.com wrote: I have a column of 1000 datapoints from the normal distribution with mean 2 and variance 4. How can I get a histogram of these observations with 20 bins with each bin having 50 observations? -- Thanks, Jim. -- Thanks, Jim. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A matching problem
Does this do what you want? (using just three letters to keep the list of results short) tmp - expand.grid(v=letters[1:3],V=LETTERS[1:3]) tmp v V 1 a A 2 b A 3 c A 4 a B 5 b B 6 c B 7 a C 8 b C 9 c C subset(tmp, tolower(tmp$V) != tmp$v) v V 2 b A 3 c A 4 a B 6 c B 7 a C 8 b C -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 7/30/12 7:55 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Dear all, I was encountering with a typical Matching problem and was wondering whether R can help me to solve it directly. Let say, I have 2 vectors of equal length: vector1 - LETTERS[1:6] vector2 - letters[1:6] Now I need to match these 2 vectors with all possible ways like: (A,B,C,D,E) (a,b,c,d,e) is 1 match. Another match can be (A,B,C,D,E) (b,a,c,d,e), however there cant be any duplication. Is there any direct way to doing that in R? Thanks and regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sprintf doesn't care of escape characters
sprintf is working just fine. Your problem is the interpretation of what the results are. Displaying the object will show the escape characters, but if you use cat, or output to a file, you will see that the result is correct: cat( sprintf(a\nb)) a b cat(sprintf(a\bc\d)) abcd On Mon, Jul 30, 2012 at 1:29 PM, Edwin Helbert Aponte Angarita helber...@gmail.com wrote: Hi. I am having trouble with something that should be simple. I am unable to get sprintf using escape sequences: sprintf(a\nb) [1] a\nb sprintf(a\bc\d) [1] a\bc\d But it seems to need them any way: sprintf(a\bcd) Error: unexpected symbol in sprintf(a\bcd Any suggestion on how to solve this issue? My R system: version _ platform x86_64-suse-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.0 year 2012 month 03 day30 svn rev58871 language R version.string R version 2.15.0 (2012-03-30) Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Optimization help
On Mon, Jul 30, 2012 at 06:51:47AM -0700, Megh Dal wrote: Hi, I have following optimization problem: Min: x1 + x2 +...+ x7 subject to: x1 + x2 = 80 x2 + x3 = 65 x3 + x4 = 40 all xi are ***positive integer***. Can somebody help me in this optimization problem? Hi. As stated, there are no constraints on x5, x6, x7. So, these will be 0. Try the following library(lpSolve) mat - rbind( c(1, 1, 0, 0), c(0, 1, 1, 0), c(0, 0, 1, 1)) obj - rep(1, times=ncol(mat)) dir - rep(=, times=nrow(mat)) rhs - c(80, 65, 40) out - lp(min, objective.in=obj, const.mat=mat, const.dir=dir, const.rhs=rhs, all.int=TRUE) out$solution [1] 55 25 40 0 Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sprintf doesn't care of escape characters
I am unable to determine what you think the problem is from your description. A wild guess is that you just don't know what you are looking at in the output. Do you understand the difference between the output of the print function and of the cat function? Try cat( sprintf(a\bc\d) ) and print ( sprintf(a\bc\d) ) In a nutshell, print makes the string suitable for inclusion in source code, while cat sends the string directly as-is. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Edwin Helbert Aponte Angarita helber...@gmail.com wrote: Hi. I am having trouble with something that should be simple. I am unable to get sprintf using escape sequences: sprintf(a\nb) [1] a\nb sprintf(a\bc\d) [1] a\bc\d But it seems to need them any way: sprintf(a\bcd) Error: unexpected symbol in sprintf(a\bcd Any suggestion on how to solve this issue? My R system: version _ platform x86_64-suse-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.0 year 2012 month 03 day30 svn rev58871 language R version.string R version 2.15.0 (2012-03-30) Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem creation tensor
On Mon, Jul 30, 2012 at 04:11:40AM -0700, GiuseppeRicci wrote: Hi, thank Petr for your help. I have implemented you code suggestion but there is another problem. It seems that the code: for (i in 1:m){ Z[i,,]=table(occ, data_matrix[,i]) } don't charge any values in Z. Is there some error? Hi. I do not see an error in this part of the code, but there may be an error in the context, in which this code is used. Did you look at the value of table(occ, data_matrix[,i]) at the time, when the command is executed? If the command Z[i,,]=table(occ, data_matrix[,i]) does not stop with an error, then it does not change Z[i,,] if Z[i,,] contains the values equal to table(occ, data_matrix[,i]) already before the command is executed. This may happen, for example, if you run the command twice. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] If/then statement, if in a list then
On Mon, Jul 30, 2012 at 8:49 AM, Bert Gunter gunter.ber...@gene.com wrote: Not necessarily. If the OP really meant the R list() structure, then is.element does not apply. Perhaps... x - list(1:5, a, `+`, rnorm, NULL, list(letters)) letters %in% x # Works -- vectorized, mostly false, but the a is there, per below a %in% x # Works, true 1 %in% x # Works, false 1:5 %in% x # Works -- vectorized, false list(1:5) %in% x # Works, true `+` %in% x # Error NULL %in% x # logical(0) so it seems is.element / %in% [chacun son gout] works with vectors (in a rather broad sense of that word) I'm still trying to understand quite how this one works though: list(letters) %in% x # Works -- false: this one surprised me! identical(list(letters), x[[6]]) # True Best, Michael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.