Re: [R] populating an array
On Wed, 14 Oct 2009, tdm wrote: Hi, Can someone please give me a pointer as to how I can set values of an array? See ?Subscript and study the examples. What do you suppose array( 1:4, dim=c(2, 2) )[1][2] is? R is not C. HTH, Chuck Why does the code below not work? my_array - array(dim=c(2,2)) my_array[][] = 0 my_array [,1] [,2] [1,]00 [2,]00 for(i in seq(1,2,by=1)){ for(j in seq(1,2,by=1)){ my_array[i][j] = 5 } } Warning messages: 1: In my_array[i][j] = 5 : number of items to replace is not a multiple of replacement length 2: In my_array[i][j] = 5 : number of items to replace is not a multiple of replacement length my_array [,1] [,2] [1,]50 [2,]50 -- View this message in context: http://www.nabble.com/populating-an-array-tp25903190p25903190.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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ 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] RPostgreSQL: unable to load shared library
Prof Brian Ripley wrote: On Wed, 14 Oct 2009, Fanfaar wrote: Hello list, I'm using R 2.9.2 on a WinXP system, and I installed the RPostgreSQL library using the package installer. When trying to load it, I get the following error: library('RPostgreSQL') Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'C:/PROGRA~1/R/R/library/RPostgreSQL/libs/RPostgreSQL.dll': LoadLibrary failure: The operating system cannot run %1. Error: package/namespace load failed for 'RPostgreSQL' So one way or the other, the DLL is not found... Does anyone know how That is not what it says: it says it cannot *load* the DLL. You need the PostgreSQL client dll in your path, and I guess that (or its version) is the problem. (Usually Windows gives you a popup with more information, and indeed on my laptop it told me LIBPQ.DLL could not be found.) And pedump suggests that it is linked against entry points by number not name, a very fragile arrangement. I always worry that packages that link to external DLLs can be very dependent on the version of that DLL (and see the above comment). I could not see a description of the version of PostgreSQL used on Uwe's ReadMe (assuming this is a binary from CRAN), and suggest (as did the Good point, I will add that version 8.3.4-1 is used on CRAN. Best, Uwe rw-FAQ) that you install RPostgreSQL from source against your own PostgreSQL installation. (That's what I do on my Windows desktop which does have PostgreSQL installed, and when I updated PostgreSQL I had to re-install PostgreSQL ) to fix this? I don't suppose DLL should be directly in my PATH, right? Thanks for any hints, Arnout __ 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. Yes another person who thinks that does not apply to them. __ 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] Removing Embedded Null characters from text/html
Hi, I'm trying to download some data from the web and am running into problems with 'embedded null' characters. These seem to indicate to R that it should stop processing the page so I'd like to remove them. I've been looking around and can't seem to identify exactly what the character is and consequently how to remove it. # THE CODE WORKS ON THIS PAGE library(RCurl) library(XML) theurl - http://en.wikipedia.org/wiki/Brazil_national_football_team; webpage - getURL(theurl) # BUT DOES NOT WORK HERE DUE TO EMBEDDED NULL CHARACTERS theurl - http://screen.yahoo.com/b?pr=1/s=nmdb=stocksvw=0b=21; webpage - getURL(theurl) Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : Failed writing body (1371 != 1461) In addition: Warning messages: 1: In curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : truncating string with embedded nul: 'ttp://finance. ## I DELETED SOME HERE FOR BREVITY## al\nData and [... truncated] 2: In curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : only read 1371 of the 1461 input bytes/characters # THIS CODE COPIES THE PROBLEMATIC PAGE TO MY COMPUTER destfile-file:///C:/projects/stock data/data/test.htm download.file ( theurl , destfile , quiet = TRUE ) # WHICH LEAVES ME WITH JUST IDENTIFYING WHAT CHARACTER IS CAUSING THE # PROBLEM AND THEN GETTING RID OF IT. I'd appreciate any advice. -- Best regards, David Young Marketing and Statistical Consultant Madrid, Spain +34 913 540 381 http://www.linkedin.com/in/europedavidyoung mailto:dyo...@telefonica.net __ 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] performing function on lists where each element is a data frame
Are you saying that sapply(xx,function(x)weighted.mean(x$H,x$N)) assuming the list of data frames was called xx, doesn't give the result you want? Could you please elaborate as to why sapply doesn't give the correct result? - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Wed, 14 Oct 2009, ewaters wrote: I have browsed the archive, and played around with a whole bunch of ways of approaching the problem, and I cannot get the answer that I want. I have a list with 2000 elements. Each element is a data frame with 2 columns. As an example, see element 1999 below. [[1999]] H N 60.54 26 10 0.31 13 11 0.12 34 13 0.00 38 40.59 37 16 0.44 9 19 0.08 13 14 0.64 39 80.75 12 24 0.42 26 90.61 111 20 0.22 9 Now, I want to caluculate the weighted mean for H in each list element, with N providing the weights. I can do this fine for an individual list element: weighted.mean(list[[1999]]$H,list[[1999]]$N) [1] 0.4456403 or even: weighted.mean(list[[i]]$H,list[[i]]$N) [1] 0.5992683 but when I try and apply it in a lopp to give me back the weighted mean for each list element, I get errors: list_blah-matrix(1:2000) for(i in 1:2000){ + list_blah[i]=weighted.mean(list[[i]]$H,list[[i]]$N)} Error in list[[i]] : subscript out of bounds I am clearly not understanding a basic syntax issue, and I am not overly skilled at using loops. I have also tried using lapply instead of a for loop, with the same problem. Asking for list[i] instead of list[[i]] gives NA results, as would be expected. Can anyone shed light? weighted.mean -- View this message in context: http://www.nabble.com/performing-function-on-lists-where-each-element-is-a-data-frame-tp25902745p25902745.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.
Re: [R] Plot overview xy plots from data frame?
On 10/15/2009 07:40 AM, Joel Fürstenberg-Hägg wrote: Hi, I've got a data frame (556 rows and 36 columns) from which I need to create several xy plots and print to pdf, in order to detect outliers and trends in the data. 16 of the columns contains numerical values, and I would like to create graphs for all combinations. It can be done manually, but creating 256 plots by hand takes time... I guess I have to iterate through the data frame, but I'm not used to do that with R. Below I've written my thoughts, trying to combine my knowledge in Java and R, just to give you the idea: pdf(FieldTrial0809Overview.pdf) int colWidth = fieldTrial[0].length; for(i=0, icolWidth, i++) { for(j=0, jcolWidth, j++) { String colI=get.fieldTrial$i; String colJ=get.fieldTrial$j; plot(fieldTrial$i~fieldTrial$j, main=colI + vs + colJ, xlab=colI, ylab=colJ) } } dev.off() Anyone who know how to solve this? Do I have to copy the 16 numerical columns to a new dataset, because they are not grouped and there are 20 additional non-numerical columns in the data frame. By the way, can the iterations be made using R, or do you have to combine with for instance Perl? Hi Joel, If by all combinations you mean all pairwise combinations, then if your numeric columns are numbers 5 to 20, you could do this: allpairs-combn(5:20,2) for(i in 1:dim(allpairs)[2]) { pdf( paste(FieldTrial0809Overview, allpairs[1,i],allpairs[2,i],sep=_)) plot(fieldTrial[,allpairs[1,i]],fieldTrial[,allpairs[2,i]],...) dev.off() } Jim __ 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] populating an array
Could you possibly consider reading An Introduction to R, especially the first few pages of chapter 5, and also a bit about vectors from chapter 2, and maybe eventually even some other parts... You have x[i][j] where length(i)==1, so x[i] will be a single element. Having [j] there makes no sense except if j==1 (in that case, it makes no difference). Why would you ask for a second element of a vector of length 1? K On Thu, Oct 15, 2009 at 8:23 AM, tdm ph...@philbrierley.com wrote: Hi, Can someone please give me a pointer as to how I can set values of an array? Why does the code below not work? my_array - array(dim=c(2,2)) my_array[][] = 0 my_array [,1] [,2] [1,]00 [2,]00 for(i in seq(1,2,by=1)){ for(j in seq(1,2,by=1)){ my_array[i][j] = 5 } } Warning messages: 1: In my_array[i][j] = 5 : number of items to replace is not a multiple of replacement length 2: In my_array[i][j] = 5 : number of items to replace is not a multiple of replacement length my_array [,1] [,2] [1,]50 [2,]50 -- View this message in context: http://www.nabble.com/populating-an-array-tp25903190p25903190.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. [[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] Understanding hclust and dendrogram
I'd recommend The Elements of Statistical Learning by Hastie, Tibshirani, and Friedman. There's a lot of good information on clustering, as well as a wealth of info on many other apsects of classification, machine learning, etc. I can be downoaded, free of charge, in PDF format, from: http://www-stat.stanford.edu/~tibs/ElemStatLearn/ HTH Fearghas On Wed, Oct 14, 2009 at 2:45 AM, Peng Yu pengyu...@gmail.com wrote: ?hclust listed several references. I'm wondering what is the best resource that explained clustering algorithms, dendrogram and various clustering algorithms that are implemented in R. Thank you! __ 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.htmlhttp://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] hardcoded paths hamper running R on heterogeneous grid
Hi, if I got it right, the --disable-rpath configuration option for R should prevent that library paths are hardcoded in R. Nevertheless, the path to the installation on R on the machine on which I originally installed R *is* hardcoded in the R startup script and also in Rscript. Is this a bug? In any case, this *characteristic* makes it impossible to run R on a heterogeneous computing grid in a setting in which R is locally installed (including required modules) on one machine and that installation is copied to each computing element. Philip -- | Philip Kensche pkens...@cmbi.ru.nl | http://www.cmbi.ru.nl/~pkensche | | Center for Molecular and Biomolecular Informatics | http://www2.cmbi.ru.nl | | phone +31 (0)24 36 19693 | fax +31 (0)24 36 19395 __ 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] Discriminant plot
Hi Alejo, According to my knowledge the two plots are different because in the first one a point belongs to a group depending on its group in the data whereas in the second plot a point belongs to the group predicted by the linear discriminant analysis. I hope somebody will correct me if I am wrong. Alain Alejo C.S. wrote: Hi Alain, this is the code: library(MASS) library(mda) #data attached, first column G3 group membership X - read.table(data, header=T) lda_analysis - lda(formula(X), data=X) plot(lda_analysis, col=palette()[X$G3]) #the above plot is completely different to: plot(predict(lda_analysis)$x, type=n) text(predict(lda_analysis)$x, labels=predict(lda_analysis)$class, col=palette()[predict(lda_analysis)$class]) The above code only reproduce the first plot using predict to obtain coordinates and classes for the first tow discriminant axis. Thanks , Alejo -- Alain Guillet Statistician and Computer Scientist SMCS - Institut de statistique - Université catholique de Louvain Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50 __ 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] Estimation in a changepoint regression with R
Dear All, I'm trying to do the estimation in a changepoint regression problem via R, but never found any suitable function which might help me to do this. Could someone give me a hand on this matter? Thank you. __ 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] packaging R
I can license the application under GPL On Wed, Oct 14, 2009 at 6:47 PM, Duncan Murdoch murd...@stats.uwo.cawrote: On 14/10/2009 6:35 PM, H Rao wrote: Hi, I am planning to use R as the backend in my application and VB as the front end. I want to be able to distribute it as a stand alone application and my users should not have to install R separately to use the application. I want to be able to integrate the R interpreter into the application so that just installing the application should take care of everything. Is this something which is possible with R Is your application licensed under the GPL, or a compatible license? . Duncan Murdoch [[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] sort dates within a factor
Hi, late, but here is the feedback. plyr was the way to go, but given my large df, plyr crashed when I applied it to the whole df. So I just took the part of the df to sort, applied plyr to it and then merged it with the original df. Thank you, Xavier Hadley! Stefan xavier.char...@free.fr schrieb, Am 29.09.2009 13:58: Apologies for the misunderstanding. I can come up with a solution that might suit your needs: library(plyr) out - ddply(test, .(nr), function(x) data.frame(date=x$date, index=rank(-as.integer(x$date out[is.na(out$nr) | is.na(out$date), index] - NA Xavier - Mail Original - De: Stefan Uhmann stefan.uhm...@googlemail.com À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 13h15:10 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [R] sort dates within a factor Hi Xavier, thank you for your suggestion, it's not exactly what I need. However I made some progress using tapply, but it does not give me the 'correct' result (see index - that's what I want to obtain!) when NAs are involved: test - data.frame(date = as.Date(c('2007-01-01','2008-03-24','NA','2003-03-02','2004-01-01','2008-05-03','2002-05-23','2001-06-30','2005-12-04')), nr = c(2000,2000,2000,2000,NA,2001,2002,2003,2003)) test # the result should look like: cbind(test, index = c(2,1,NA,3,NA,1,1,2,1)) # tapply does not treat NAs as intended unlist(tapply(test$date, test$nr, function(x){order(x, decreasing = T)})) Kind Regards, Stefan xavier.char...@free.fr schrieb, Am 29.09.2009 12:12: Is this what you want? test[order(test$nr, -as.integer(test$date)),] Xavier - Mail Original - De: Stefan Uhmann stefan.uhm...@googlemail.com À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 11h27:20 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: [R] sort dates within a factor Dear List, I have the following data: test - data.frame(date = as.Date(c('2007-01-01','2008-03-24','2003-03-02','2008-05-03','2002-05-23','2001-06-30','2005-12-04')), nr = c(2000,2000,2000,2001,2002,2003,2003)) test date nr 1 2007-01-01 2000 2 2008-03-24 2000 3 2003-03-02 2000 4 2008-05-03 2001 5 2002-05-23 2002 6 2001-06-30 2003 7 2005-12-04 2003 and would like a result which looks as follows, i.e. that sorts the dates within the factor starting with the last one: cbind(test, index = c(2,1,3,1,1,2,1)) date nr index 1 2007-01-01 2000 2 2 2008-03-24 2000 1 3 2003-03-02 2000 3 4 2008-05-03 2001 1 5 2002-05-23 2002 1 6 2001-06-30 2003 2 7 2005-12-04 2003 1 I've done sth. similar before, but I have difficulties to figure it out this time. Thanks for your help in advance! Regards, Stefan __ 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-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] change order of bar plot categories
Hi Tobias and Felipe, Both of your methods changed to the labels (L,M,H), but not the corresponding values. The methods graph L as H, M as L, and M and H. I have had display problems using ggplot2 before, but it seemed as if it was because I was using Windows XP. I ran the current code using Ubuntu 9.04 and got the same display issue. Here is the code again, because I forgot to hard code the numbers. temp-factor(c(rep(Low,2),rep(Medium,2),rep(High,2))) levels = c(Low, Medium, High)) light-rep(c(Dark,light),3) avg-c(0.520,0.780, 0.300, 0.600, 0.060, 0.6078431) se-c(0.07065409, 0.05858327, 0.06480741, 0.06928203, 0.03358571, 0.06904634) dat.avg.temp-data.frame(cbind(avg,se)) dat.avg.temp-data.frame(cbind(temp,light,dat.avg.temp)) dat.plot-qplot(light,avg, fill=factor(temp),data=dat.avg.temp, geom=bar, position=dodge)+ scale_fill_discrete(Temp,labels=c('Low','Medium','High')) dat.plot Thanks again for any help. Wade On Wed, Oct 14, 2009 at 4:19 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Is this what you want? temp-c(rep(Low,2),rep(Medium,2),rep(High,2)) light-rep(c(Dark,light),3) avg-dat.avg2[,3] # se-dat.avg2[,4] dat.avg.temp-data.frame(cbind(avg,se)) dat.avg.temp-data.frame(cbind(temp,light,dat.avg.temp)) dat.plot-qplot(light,avg, fill=factor(temp),data=dat.avg.temp, geom=bar, position=dodge) + scale_fill_discrete(Temp,labels=c('Low','Medium','High')) dat.plot Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Wed, 10/14/09, Wade Wall wade.w...@gmail.com wrote: From: Wade Wall wade.w...@gmail.com Subject: change order of bar plot categories To: ggplot2 ggpl...@googlegroups.com Date: Wednesday, October 14, 2009, 12:40 PM Hi all, I am trying to change the order of bar plot categories, and not sure how to do. I am graphing temperature means (low, medium, and high) and want them in increasing temperature order, but qplot puts them in alphabetical order. Any way to manually instruct qplot regarding the order. Here is some example code. The temperatures are arranged in the order I would like them (first column). temp-c(rep(Low,2),rep(Medium,2),rep(High,2)) light-rep(c(Dark,light),3) avg-dat.avg2[,3] se-dat.avg2[,4] dat.avg.temp-data.frame(cbind(avg,se)) dat.avg.temp-data.frame(cbind(temp,light,dat.avg.temp)) dat.plot-qplot(light,avg, fill=factor(temp),data=dat.avg.temp, geom=bar, position=dodge) Any help would be appreciated, Wade --~--~-~--~~~---~--~~ You received this message because you are subscribed to the ggplot2 mailing list. To post to this group, send email to ggpl...@googlegroups.com To unsubscribe from this group, send email to ggplot2+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/ggplot2 -~--~~~~--~~--~--~--- __ 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] Estimation in a changepoint regression with R
There are at least two R packages dealing with changepoint estimation, segmented and strucchange. Two possible relevant papers are available: 1)Journal of Statistical Software for strucchange (2002, Vol.7, Issue2) 2)Rnews for segmented (2008, 8/1: 20-25) Hope this helps you vito FMH ha scritto: Dear All, I'm trying to do the estimation in a changepoint regression problem via R, but never found any suitable function which might help me to do this. Could someone give me a hand on this matter? Thank you. __ 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. -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 http://dssm.unipa.it/vmuggeo __ 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] scatterplot3d bug??
Uwe Ligges wrote: I finally found some time to look at it: Yes, it does not work properly for angles 180 degrees. Will try to find a fix and make a new release soon. Late, but finally the fixed version is on its way to CRAN. Best wishes, Uwe Ligges Best wishes, Uwe Ligges Vivek Ayer wrote: Hey guys, Not sure if I encountered a bug with the scatterplot3d function. Here's the calls I made: s3d1 - scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=40,type=h,main=MRSL ~ LogDist + Diff); s3d1$plane3d(fitols); s3d1 - scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=130,type=h,main=MRSL ~ LogDist + Diff); s3d1$plane3d(fitols); s3d1 - scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=210,type=h,main=MRSL ~ LogDist + Diff); s3d1$plane3d(fitols); s3d1 - scatterplot3d(TotLogDisttenp,TotDifftenp,TotMeasuredRSLtenp,pch=16,highlight.3d=TRUE,angle=310,type=h,main=MRSL ~ LogDist + Diff); s3d1$plane3d(fitols); Essentially four plots showing the data from different angles. This includes the fit plane. The first two graphs make sense, but for the latter two, the fit plane is not making sense. Take a look at the attached png. Is it a bug? Thanks, Vivek __ 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-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] packaging R
On 15/10/2009 7:00 AM, H Rao wrote: I can license the application under GPL On Wed, Oct 14, 2009 at 6:47 PM, Duncan Murdoch murd...@stats.uwo.ca mailto:murd...@stats.uwo.ca wrote: On 14/10/2009 6:35 PM, H Rao wrote: Hi, I am planning to use R as the backend in my application and VB as the front end. I want to be able to distribute it as a stand alone application and my users should not have to install R separately to use the application. I want to be able to integrate the R interpreter into the application so that just installing the application should take care of everything. Is this something which is possible with R Is your application licensed under the GPL, or a compatible license? . Then I don't think there's any basis for an objection. The only issues are in doing it: we use Inno Setup as our installer, and it could certainly set things up for you. The easiest way to do this is to make a model installation on your own machine, then run Inno Setup to make an installer from it. If your application needs configuration (e.g. setting local directories, registry entries, etc.) then it's more work, but it's all fairly straightforward. R can make use of such customizations (and our installer does them), but it doesn't need them. Duncan Murdoch __ 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: combine multiple 'pairs plots'
I would like to combine multiple pairs plots (each one being a matrix of correlation plots) into a single graphic. I have tried the par() function, which works well to combine several simple graphs. However, the pairs() graph seems to override the par() function and produce an new plot, rather than combining the plots into a single graphic. Thanks, Jesse __ 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] plotting/examining residuals of a mixed generalised linear model
kath_oreilly wrote: Dear R users, I'm hoping that more experienced users will be able to assist me in examining the model fit of a mixed generalised linear model. The example using the data 'bacteria' within the MASS package will hopefully illustrate what I would like to acheive; I think you're a little confused. Thanks for the reproducible example, though. First of all, you're confusing nlme (old mixed models, described most thoroughly in Pinheiro and Bates 2000, good for correlation and heteroscedasticity models but not capable of doing GLMMs) with lme4 (new mixed models, not yet thoroughly documented but D. Bates is working on a book ...) Mixing them is usually a bad idea. The plotting capabilities aren't as highly developed for lme4 as for nlme, but you can still get what you want done. The r-sig-mixed-models list may be better for this kind of question. Here's my solution to your problem: library(MASS) data(bacteria) with(bacteria,table(y,trt)) library(lme4) bacteria$pres - as.numeric(bacteria$y==y) ## derive 0/1 variable model - lmer(pres ~ trt + (week|ID),family=binomial,data=bacteria) summary(model) with(bacteria,boxplot(residuals(model)~trt)) ## or boxplot(residuals(model)~bacteria$trt) -- View this message in context: http://www.nabble.com/plotting-examining-residuals-of-a-mixed-generalised-linear-model-tp25905522p25908589.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] ltm package error for grm (IRT)
Ben, This is because you do not have all the possible response options represented for each item. For example, in your data below, item 2 has no '1's. I don't know if there is a workaround for this (other than deleting an item or faking a response), or if this is a function of IRT itself? Tom Fletcher -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of ben kelcey Sent: Wednesday, October 14, 2009 4:32 PM To: r-help@r-project.org Subject: [R] ltm package error for grm (IRT) Using the grm function (graded response IRT model) in the ltm package I receive the following error: Error: subscript out of bounds for several scales I'd like to examine. Here's a small example that if run a few times will likley produce the error at least once ch-array(round(runif(50,1,5)),c(10,5)) grm(ch,start.val=random) ## or grm(ch,constrained=F,IRT.param=T,start.val=random) I have cannot figure out where I have gone wrong and was unable to find mention of similar errors in the archives. Any help would be much appreciated. A subset of my actual data that produces the same error is pasted below Thank you, ben t2_sr1 t2_sr2 t2_sr3 t2_sr4 t2_sr5 1 5 1 5 5 1 4 1 4 4 4 2 4 2 1 4 5 4 1 4 1 5 5 1 5 1 4 1 5 5 3 2 4 2 4 5 3 5 1 1 4 2 4 4 2 1 4 1 4 5 2 4 4 4 2 1 4 2 3 4 2 2 4 3 2 2 4 2 3 3 4 3 2 3 3 2 5 2 5 5 1 4 1 4 4 3 3 2 3 4 2 4 2 3 4 3 3 3 2 2 sessionInfo() R version 2.9.2 (2009-08-24) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] splines stats graphics grDevices utils datasets methods base other attached packages: [1] car_1.2-16 epicalc_2.9.2.7 survival_2.35-4 foreign_0.8-37 faraway_1.0.4 [6] ltm_0.9-1 polycor_0.7-7 sfsmisc_1.0-8 mvtnorm_0.9-7 msm_0.9.3 [11] MASS_7.2-48 loaded via a namespace (and not attached): [1] tools_2.9.2 [[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.
[R] LondonR Meeting - Free event
Hi all, The LondonR meeting is finally approaching and I am pleased to say that the venue and agenda have been finalised. Thank you to everyone who has already confirmed their places, and a little reminder to those who have yet to do so. I really hope you can all make it, and I look forwards to seeing you there. Please don't hesitate to contact me if you have any queries. Sarah Lewis mangosolutions data analysis that delivers T: +44 (0)1249 767700 LondonR agenda Date: Tuesday 3rd November Time: 6pm - 9.30pm Venue: Shooting Star Public house, 129 City Rd London, EC1, United Kingdom +44 20 7929 6818 Introduction: Richard Pugh - mangosolutions * 6.15pm: Richard Saldanha R in the City * 6.50pm: Luca Sbardella A use of R from within python for quantitative finance applications * 7.25pm: Charles Roosen Enhancing Spotfire with the Power of R * 8.00pm: Andrei Serjantov Introduction to Functional programming in R * 8.35pm: John James and Romain Francois Keeping R at a distance: calling R using a local interface * 9.10pm: Drinks and Networking Many thanks Sarah Lewis mangosolutions data analysis that delivers T: +44 (0)1249 767700 F: +44 (0)1249 767707 M: +44 (0)7966 062462 Unit 2 Greenways Business Park Bellinger Close Chippenham Wilts SN15 1BN UK [[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] RPostgreSQL: unable to load shared library
Thanks, Brian and Joe, for the explanations. The libpq DLL was indeed the problem. FYI, it seems to load fine using the PostgreSQL 8.4 libpq.gll, if further testing reveals problems I'll report it back. Arnout On Wed, Oct 14, 2009 at 4:33 PM, Fanfaar fanf...@gmail.com wrote: Hello list, I'm using R 2.9.2 on a WinXP system, and I installed the RPostgreSQL library using the package installer. When trying to load it, I get the following error: library('RPostgreSQL') Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'C:/PROGRA~1/R/R/library/RPostgreSQL/libs/RPostgreSQL.dll': LoadLibrary failure: The operating system cannot run %1. Error: package/namespace load failed for 'RPostgreSQL' So one way or the other, the DLL is not found... Does anyone know how to fix this? I don't suppose DLL should be directly in my PATH, right? Thanks for any hints, Arnout __ 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] Complex? import of pdf files (criminal records) into R table
Hi there, I'm facing the decision if it would be possible to transform several more or less complex pdf files into an R Table-Format or if it has to be done manually. I think it would be a impudent to expect a complete solution, but I would be grateful if anyone could give me an advice on how the structure of such a R-program could look like, and if it's possible in general. Here the problem: Each pdf file belongs to a person. The pdf files actually represent the anonymous criminal record of a person. Each entry should lead to one row with the person number as key. The different lines should form the columns. The criminal record actually looks like this: --- Header with irrelevant text for us | Date: xx.xx. (relevant for us) Anonymous person number: xxx Entries in the register 1. xx.xx.1902 -City- Be in force since: xx.xx.1902 Date of offense:xx.xx. Elements of the offence: For example Rape Section in law: §176, §178 Abs. 1 Sentenced to 5 years imprisonment Irrelevant text for us Accommodation in an forensic psychiatry Accommodation sentenced on probation Rest of sentence sentenced on probation until the xx.xx. 2. xx.xx.1910 Be in force since: . --- The problem is that the entries do not always have the same structure. The first 6 lines are structurally the same in each entry of the criminal record (each entry has a line for the judgement date, the be in force date, the date of offence, the elements of the offence, the Sections in law, and the sentence). But then depending on the sentence different lines emerge which contain information if the person was sentenced on probation, if the probation was withdrawn again, when the person was released etc. So, I think, these lines should be allocated to different columns depending on key words. The definition of the key words for most cases would not be the problem, actually. If a certain column is not relevant in an entry (so, the key word didn't emerge) NA should be put in the place. But because sometimes (in rare cases), the entries contain spelling errors, at the end, all the lines of an entry, which could not be allocated to a column should be put in a column to check them manually. In the end the table should look more of less like this. -- Per.Numb;EntryNumber;Judg.Date;DateOffen.;...;Probation.until; Released;Not allocated 1 1 xx.xx.1902 xx.xx.1901 ... xx.xx.1905 NA blablabla 1 2 xx.xx.1910 xx.xx.1909 ... NA1925 blablabla 2 1 xx.xx.1924 xx.xx.1923 ... NANA blablabla -- Could anyone help me? Thanks Greetings Jürgen __ 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] plotting/examining residuals of a mixed generalised linear model
Dear R users, I'm hoping that more experienced users will be able to assist me in examining the model fit of a mixed generalised linear model. The example using the data 'bacteria' within the MASS package will hopefully illustrate what I would like to acheive; library(MASS) library(nlme) attach(bacteria) # y being output and the trt - treatment group being an explanatory variable. There is pseudoreplication as each patient (ID) is sampled multiple times (week) bacteria$y-1*(bacteria$y==y) # to make readable in lmer table(bacteria$y,bacteria$trt) hs - groupedData(y~trt|ID,outer=~trt,data=bacteria) # I don't think this is really necessary model - lmer(y ~ trt + (week|ID),family=binomial,data=hs) summary(model) Here I would like to examine the fit of the variable trt by examining the residuals. In lm (using lme in the R book, p. 657), one would be able to use plot(model,trt~resid(.)) However it doesn't work. If some one would explain why, that would be great. I've come across the package zelig, which uses simulation to examine model fit. I haven't gotten my head round this yet, and was hoping some one would advise the approp path to take. Many thanks! -- View this message in context: http://www.nabble.com/plotting-examining-residuals-of-a-mixed-generalised-linear-model-tp25905522p25905522.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] Handle lot of variables - Regression
Thank you very much! Now it works! I'm aware of the fact, that practically seen it's maybe nonsense to do something like this. But I have to do a Monte Carlo simulation where I want to determine some aspects... It's a complicated story, but a logistic regression (stepwise or not) is a basis for my analysis and I want to try both. Anna Dieter Menne wrote: anna0102 wrote: I've got a data set (e.g. named Data) which contains a lot of variables, for example: s1, s2, ..., s50 My first question is: It is possible to do this: Data$s1 But is it also possible to do something like this: Data$s1:s50 (I've tried a lot of versions of those without a result) Use the [] notation. For example Data[,c(s1,s2,s3)] or even better Data[,grep(s.*,names(a),value=TRUE)] anna0102 wrote: I want to do a stepwise logistic regression. For this purpose I use the following procedures: result-glm(...) step(result, direction=forward) Now the problem I have, is, that I have to include all my 50 variables (s1-s50), but I don't want to write them all down like y~s1+s2+s3+s4... (furthermore it has to be implemented in a loop, so I really need it). Construct the formula dynamically. But please, start with only 3 or 4 variables and try if it work. Sometimes deep inside functions things can go wrong with this method, requiring Ripley's game-like workarounds. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/16599.html a=data.frame(s=1:10,s2=1:10,s4=1:10) form = paste(z~,grep(s.*,names(a),value=TRUE),collapse=+) glm(form,) And be aware of the nonsense you can (replace by will certainly) get with stepwise regression and so many parameters. If I were to be treated by a cure created by stepwise regression, I would prefer voodoo. Search for Harrell stepwise read Frank's well justified soapboxes. Dieter -- View this message in context: http://www.nabble.com/Handle-lot-of-variables---Regression-tp25889056p25903765.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] help: combine multiple 'pairs plots'
Don't know if it will work, but did you try ?layout ? Cheers Joris On Thu, Oct 15, 2009 at 2:39 PM, Jesse Poland jap...@cornell.edu wrote: I would like to combine multiple pairs plots (each one being a matrix of correlation plots) into a single graphic. I have tried the par() function, which works well to combine several simple graphs. However, the pairs() graph seems to override the par() function and produce an new plot, rather than combining the plots into a single graphic. Thanks, Jesse __ 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] help: combine multiple 'pairs plots'
Don't know if it will work, but did you try ?layout ? Otherwise you can take a look at ?split.screen too. Cheers Joris On Thu, Oct 15, 2009 at 2:39 PM, Jesse Poland jap...@cornell.edu wrote: I would like to combine multiple pairs plots (each one being a matrix of correlation plots) into a single graphic. I have tried the par() function, which works well to combine several simple graphs. However, the pairs() graph seems to override the par() function and produce an new plot, rather than combining the plots into a single graphic. Thanks, Jesse __ 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] Lattice package - Trellis
Hi, I was trying to make a graph using trellis, and my code is: - library(lattice) makeGraph - function(){ trellis.device() tbg - trellis.par.get(background) tbg$col - white trellis.par.set(background,tbg) # Test Data mfr - matrix(sample(1:100,50,replace=T),ncol=2) mfr - cbind(mfr,c(rep(1,12),rep(2,13))) mfr - cbind(mfr,c(rep(All,6),rep(Reduced,6),rep(All,7),rep(Reduced,6))) colnames(mfr) - c(PVAL,POSITION,CHR,METHOD) mfr - as.data.frame(mfr) pdf(file='test.pdf') op - par(no.readonly=TRUE) xyplot(as.numeric(as.vector(PVAL)) ~ as.numeric(as.vector(POSITION)) | CHR, data = mfr, groups = METHOD, ylab = pval, xlab = position, type=p,col=c(green,red) ) par(op) dev.off() } makeGraph() ___ However, when I execute the code I don't get the graph. Although a pdf is generated, it is only 1 KB and when I try to open the pdf a message comes up that says there are no pages in the pdf. Interestingly, if I take the code (i.e. from line 'trellis.device()' to line 'dev.off') out of the function call and execute it, the pdf is generated just fine. What am I doing wrong? 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.
[R] Sampling procedure
I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example - matrix(c(1:783),ncol = 1) s1 - as.matrix(sample(Example,87, re = FALSE)) Example - Example[-s1] s2 - as.matrix(sample(Example,87, re = FALSE)) #however I don´t know how to remove the second group from the Example to continue sampling. There is probably an easy and faster way to do this. Could anybody help me? Thanks -- View this message in context: http://www.nabble.com/Sampling-procedure-tp25909497p25909497.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] Complex? import of pdf files (criminal records) into R table
On Oct 15, 2009, at 3:43 AM, Biedermann, Jürgen wrote: Hi there, I'm facing the decision if it would be possible to transform several more or less complex pdf files into an R Table-Format or if it has to be done manually. I think it would be a impudent to expect a complete solution, but I would be grateful if anyone could give me an advice on how the structure of such a R-program could look like, and if it's possible in general. Here the problem: Each pdf file belongs to a person. The pdf files actually represent the anonymous criminal record of a person. Each entry should lead to one row with the person number as key. The different lines should form the columns. The criminal record actually looks like this: --- Header with irrelevant text for us | Date: xx.xx. (relevant for us) Anonymous person number: xxx Entries in the register 1. xx.xx.1902 -City- Be in force since: xx.xx.1902 Date of offense:xx.xx. Elements of the offence: For example Rape Section in law: §176, §178 Abs. 1 Sentenced to 5 years imprisonment Irrelevant text for us Accommodation in an forensic psychiatry Accommodation sentenced on probation Rest of sentence sentenced on probation until the xx.xx. 2. xx.xx.1910 Be in force since: . --- The problem is that the entries do not always have the same structure. The first 6 lines are structurally the same in each entry of the criminal record (each entry has a line for the judgement date, the be in force date, the date of offence, the elements of the offence, the Sections in law, and the sentence). But then depending on the sentence different lines emerge which contain information if the person was sentenced on probation, if the probation was withdrawn again, when the person was released etc. So, I think, these lines should be allocated to different columns depending on key words. The definition of the key words for most cases would not be the problem, actually. If a certain column is not relevant in an entry (so, the key word didn't emerge) NA should be put in the place. But because sometimes (in rare cases), the entries contain spelling errors, at the end, all the lines of an entry, which could not be allocated to a column should be put in a column to check them manually. In the end the table should look more of less like this. -- Per .Numb;EntryNumber;Judg.Date;DateOffen.;...;Probation.until; Released;Not allocated 1 1 xx.xx.1902 xx.xx.1901 ... xx.xx.1905 NA blablabla 1 2 xx.xx.1910 xx.xx.1909 ... NA1925 blablabla 2 1 xx.xx.1924 xx.xx.1923 ... NANA blablabla -- Could anyone help me? Thanks Greetings Jürgen You don't indicate the OS you are on, but you will want to get a hold of 'pdftotext', which is a command line application that can extract the textual content from the PDF files. On most Linuxen, it is already installed, but for Windows and OSX you will likely need to Google for it. The basic approach is to loop over each PDF file, use pdftotext to get the text content and dump it into a regular text file. That file can then be read into R using ?readLines. This can all be done within R using the ?system command. Get the names of the PDF files in a given folder by using ?list.files with a \ \.pdf or \\.PDF search pattern. Then ?paste together the full command using a prefix along the lines of pdftotext -layout - nopgbrk, presuming that the pdftotext command is in your $PATH. The suffix to be paste()d will be the name of the input PDF file and the name of the output text file. So you end up with a command line character vector along the lines of: pdftotext -layout -nopgbrk x.pdf x.txt where the x's are the specific file basenames. Review the pdftotext options to understand what is being done and if you should need to modify them for your particular files. Once you have the data in R for each file, you will then need to process the content line by line, looking for the keywords that are associated with the content you require. Using ?grep is perhaps the easiest way to accomplish that. You can then use ?gsub to replace/ strip the keywords, leaving you with the data only, for each line. For multi line scenarios, you will need to keep track of where the keyword for the first line is and then look for the subsequent keyword or perhaps a blank line, to know when to stop aggregating the data for that initial keyword. It then becomes a matter of reorganizing the content that you need into the format you require for subsequent work. I have not looked for 'text processing' related packages on CRAN, so you may wish to look there
Re: [R] Lattice package - Trellis
Perhaps you've not read FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f -- David On Oct 15, 2009, at 10:18 AM, Paul Evans wrote: Hi, I was trying to make a graph using trellis, and my code is: - library(lattice) makeGraph - function(){ trellis.device() tbg - trellis.par.get(background) tbg$col - white trellis.par.set(background,tbg) # Test Data mfr - matrix(sample(1:100,50,replace=T),ncol=2) mfr - cbind(mfr,c(rep(1,12),rep(2,13))) mfr - cbind(mfr,c(rep(All,6),rep(Reduced,6),rep(All, 7),rep(Reduced,6))) colnames(mfr) - c(PVAL,POSITION,CHR,METHOD) mfr - as.data.frame(mfr) pdf(file='test.pdf') op - par(no.readonly=TRUE) xyplot(as.numeric(as.vector(PVAL)) ~ as.numeric(as.vector(POSITION)) | CHR, data = mfr, groups = METHOD, ylab = pval, xlab = position, type=p,col=c(green,red) ) par(op) dev.off() } makeGraph() ___ However, when I execute the code I don't get the graph. Although a pdf is generated, it is only 1 KB and when I try to open the pdf a message comes up that says there are no pages in the pdf. Interestingly, if I take the code (i.e. from line 'trellis.device()' to line 'dev.off') out of the function call and execute it, the pdf is generated just fine. What am I doing wrong? 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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Sampling procedure
On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote: I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example - matrix(c(1:783),ncol = 1) Example - matrix(c(1:783),ncol = 1) Grp1 - sample(Example, 87, replace=FALSE) Grp2 - sample(Example[-Grp1], 87, replace=FALSE) Grp3 - sample(Example[-c(Grp1, Grp2)], 87, replace=FALSE) # lather, rinse , repeat s1 - as.matrix(sample(Example,87, re = FALSE)) Example - Example[-s1] s2 - as.matrix(sample(Example,87, re = FALSE)) #however I don´t know how to remove the second group from the Example to continue sampling. #Don't mess up the original There is probably an easy and faster way to do this. Could anybody help me? Thanks -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Best way to get stock quotes
What is preferred/better, get.hit.quote, priceIts, or other? -- View this message in context: http://www.nabble.com/Best-way-to-get-stock-quotes-tp25903585p25903585.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] converting to data.frame
dear allI have a data set with three types (Tree, Sapling, Seedling). I have estimated the correlation values. now i need to bring all the correlation values in a table like the one i have shown in attached file with R codes.could you please give me idea on this problem thanking you MSNepal _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/read.table() colnames(c.df) [1] id codelonglat elevage_obs year [8] Est_age Ht_cm BD_mm CDA_cm CDB_cm growth type ### Correlation estimation cor(age_obs,Ht_cm) cor(age_obs[type=='SD'],Ht_cm[type=='SD']) #seedling cor(age_obs[type=='SPB'],Ht_cm[type=='SPB'])#sapling cor(age_obs[type=='T'],Ht_cm[type=='T'])#tree cor(age_obs,BD_mm) cor(age_obs[type=='SD'],BD_mm[type=='SD']) cor(age_obs[type=='SPB'],BD_mm[type=='SPB']) cor(age_obs[type=='T'],BD_mm[type=='T']) cor(age_obs,CDA_cm) cor(age_obs[type=='SD'],CDA_cm[type=='SD']) cor(age_obs[type=='SPB'],CDA_cm[type=='SPB']) cor(age_obs[type=='T'],CDA_cm[type=='T']) cor(age_obs,CDB_cm) cor(age_obs[type=='SD'],CDB_cm[type=='SD']) cor(age_obs[type=='SPB'],CDB_cm[type=='SPB']) cor(age_obs[type=='T'],CDB_cm[type=='T']) cor(Ht_cm,BD_mm) cor(Ht_cm[type=='SD'],BD_mm[type=='SD']) cor(Ht_cm[type=='SPB'],BD_mm[type=='SPB']) cor(Ht_cm[type=='T'],BD_mm[type=='T']) cor(Ht_cm,CDA_cm) cor(Ht_cm[type=='SD'],CDA_cm[type=='SD']) cor(Ht_cm[type=='SPB'],CDA_cm[type=='SPB']) cor(Ht_cm[type=='T'],CDA_cm[type=='T']) cor(Ht_cm,CDB_cm) cor(Ht_cm[type=='SD'],CDB_cm[type=='SD']) cor(Ht_cm[type=='SPB'],CDB_cm[type=='SPB']) cor(Ht_cm[type=='T'],CDB_cm[type=='T']) cor(BD_mm,CDA_cm) cor(BD_mm[type=='SD'],CDA_cm[type=='SD']) cor(BD_mm[type=='SPB'],CDA_cm[type=='SPB']) cor(BD_mm[type=='T'],CDA_cm[type=='T']) cor(BD_mm,CDB_cm) cor(BD_mm[type=='SD'],CDB_cm[type=='SD']) cor(BD_mm[type=='SPB'],CDB_cm[type=='SPB']) cor(BD_mm[type=='T'],CDB_cm[type=='T']) cor(CDA_cm,CDB_cm) cor(CDA_cm[type=='SD'],CDB_cm[type=='SD']) cor(CDA_cm[type=='SPB'],CDB_cm[type=='SPB']) cor(CDA_cm[type=='T'],CDB_cm[type=='T']) cor(age_obs,Est_age,use=pairwise.complete.obs) cor(age_obs[type=='SD'],Est_age[type=='SD'],use=pairwise.complete.obs) cor(age_obs[type=='SPB'],Est_age[type=='SPB'],use=pairwise.complete.obs) cor(age_obs[type=='T'],Est_age[type=='T'],use=pairwise.complete.obs) ### table looks like below one parameters combinedseedlingsapling tree age_obs Vs Ht_cm age_obs Vs BD_mm age_obs Vs CDA_cm age_obs Vs CDB_cm Ht_cm Vs BD_mm Ht_cm Vs CDA_cm Ht_cm Vs CDB_cm BD_mm Vs CDA_cm BD_mm Vs CDB_cm CDA_cm Vs CDB_cm age_obs Vs est_age __ 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] Complex? import of pdf files (criminal records) into R table
On Thu, Oct 15, 2009 at 3:28 PM, Marc Schwartz marc_schwa...@me.com wrote: On Oct 15, 2009, at 3:43 AM, Biedermann, Jürgen wrote: You don't indicate the OS you are on, but you will want to get a hold of 'pdftotext', which is a command line application that can extract the textual content from the PDF files. That's assuming the text is in the PDF as a text object. If it's a scan of a paper document the chances are that all you have is an image, in which case you need to do OCR (optical character recognition) or get someone to type it all in again. Even if you can get all the text out with pdftext, R might not be the right tool for the job - I'd do this kind of text processing and matching job in Python (and before Python, I'd have used Perl). But if all you have is a wRench... Barry __ 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] Can R do specific factor analysis?
On Wed, Oct 14, 2009 at 7:00 PM, Tiger Guo tigerguou...@gmail.com wrote: Hello, Can R do factor analysis using eigenvalue greater than one to automatically determine the number of factors to extract? You could write code automate this, but it's easy enough to look at the scree plot and use that as to identify the number of factors that meet this criterion. I am afraid that R cannot provide the function we want. Unlikely! R is also a programing language, so it if the function you want doesn't exist yet you can write it yourself. But I can use R to write a function to do the specific factor analysis. Because the functions needed for developing the factor analysis is provided by R, it should be easy to write the factor analysis. Yes, I'm confident you will be able to do the analysis in R, although... I'm not sure exactly what it is that you want to do. I appreciate if someone can give me some comment about the specific factor analysis. I'm not sure what specific factor analysis means. I personally use the fa() function in the psych package. If your concern is with determining the number of factors to extract, you may be interested in the fa.parallel function in the same package. -Ista Thanks. Gencheng Guo ECE, University of Alberta, Edmonton, Alberta, Canada [[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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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] Sampling procedure
If I understand what is wanted correctly, this can be a one-liner! -- think whole objects: splitup - function(x,n.groups) #split x into n.groups mutually exclusive sets { lx - length(x) if(n.groups = lx) stop(Number of groups greater than vector length) x - x[sample(lx,lx)] split(x,seq_len(n.groups)) } ## testit splitup(1:71,9) $`1` [1] 22 26 38 50 65 60 9 27 $`2` [1] 24 2 69 28 71 31 41 13 $`3` [1] 16 47 63 45 23 1 8 32 $`4` [1] 34 39 64 35 7 19 4 55 $`5` [1] 54 10 37 68 6 17 70 18 $`6` [1] 61 11 5 46 33 43 14 56 $`7` [1] 42 44 12 62 66 48 57 58 $`8` [1] 21 40 30 29 20 49 52 67 $`9` [1] 59 15 25 51 3 36 53 Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Thursday, October 15, 2009 7:55 AM To: Marcio Resende Cc: r-help@r-project.org Subject: Re: [R] Sampling procedure On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote: I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example - matrix(c(1:783),ncol = 1) Example - matrix(c(1:783),ncol = 1) Grp1 - sample(Example, 87, replace=FALSE) Grp2 - sample(Example[-Grp1], 87, replace=FALSE) Grp3 - sample(Example[-c(Grp1, Grp2)], 87, replace=FALSE) # lather, rinse , repeat s1 - as.matrix(sample(Example,87, re = FALSE)) Example - Example[-s1] s2 - as.matrix(sample(Example,87, re = FALSE)) #however I don´t know how to remove the second group from the Example to continue sampling. #Don't mess up the original There is probably an easy and faster way to do this. Could anybody help me? Thanks -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Complex? import of pdf files (criminal records) into R table
On Oct 15, 2009, at 10:10 AM, Barry Rowlingson wrote: On Thu, Oct 15, 2009 at 3:28 PM, Marc Schwartz marc_schwa...@me.com wrote: On Oct 15, 2009, at 3:43 AM, Biedermann, Jürgen wrote: You don't indicate the OS you are on, but you will want to get a hold of 'pdftotext', which is a command line application that can extract the textual content from the PDF files. That's assuming the text is in the PDF as a text object. If it's a scan of a paper document the chances are that all you have is an image, in which case you need to do OCR (optical character recognition) or get someone to type it all in again. Good point...a scanned image would certainly complicate matters. Even with OCR, you introduce the potential for error in the the translation of the image to text and risk formatting issues, which can lead to inconsistencies in page layouts. Cheers, Marc __ 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] help: combine multiple 'pairs plots'
Thanks. However, for each function [ par(mfrow=..); layout(); and split.screen()] the pairs() graphic function creates an new graphic rather than combining into a single graphic. joris meys wrote: Don't know if it will work, but did you try ?layout ? Otherwise you can take a look at ?split.screen too. Cheers Joris On Thu, Oct 15, 2009 at 2:39 PM, Jesse Poland jap...@cornell.edu wrote: I would like to combine multiple pairs plots (each one being a matrix of correlation plots) into a single graphic. I have tried the par() function, which works well to combine several simple graphs. However, the pairs() graph seems to override the par() function and produce an new plot, rather than combining the plots into a single graphic. Thanks, Jesse __ 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] Subset returning unexpected result
Dear all, I am attempting to subset a data frame based on a range of latitude values. I want to extract the values of 'interception' where latitude ranges between 50 and 60. I am doing this using the following code, yet it doesn't return the results I expected: test - subset(int1901, Latitude=50 Latitude 60, select=c(Latitude, Interception)) head(test) Latitude Interception 2 6.25 0.04725863 3 6.75 67.02455139 82 50.75 51.74784088 83 51.25 57.04327774 84 51.75 51.51020432 85 52.25 53.30662537 As you can see, latitude values outside the 50 to 60 range have been retained (e.g. the top two rows of 'test'). Why is this, and how can I ensure that I subset the data as initially intended? Many thanks for any help offered, Steve __ 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] changing a matrix from class data.frame to class dist
Dear, I have a data frame object (FSTc) which is in fact a matrix of class data.frame but created from a txt file using the command FSTc-read.table(FSTcmatrix.txt, header=T) I would like to transform it in a distance matrix of class dist to use it with the ade4 package. I'm quite sure this is a simple operation but i just don't have the commands. Could anyone help? Thank you Maxime -- Maxime Pauwels Researcher ID: http://www.researcherid.com/rid/A-1745-2009 Laboratoire de Génétique et Evolution des Populations Végétales UMR CNRS 8016 Université de Lille, USTL-Lille1 http://gepv.univ-lille1.fr Tel : +33 3 20 43 40 76 Fax : +33 3 20 43 69 79 «Impose ta chance, serre ton bonheur et va vers ton risque. A te regarder, ils s’habitueront.» René Char __ 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] Bug in cut.POSIXt
Hello Everyone, Before reporting decided to post here first: tt - structure(c(1254238817, 1254238859, 1254238969, 1254239080), class = c(POSIXt, POSIXct), tzone = ) cut.POSIXt(tt, 2) #Error in `levels-.factor`(`*tmp*`, value = character(0)) : # number of levels differs cut.POSIXt(tt, 2, labels=c(a1, a2)) #[1] a1 a1 a2 a2 #Levels: a1 a2 cut(tt, 2 mins) #[1] 2009-09-29 17:40:00 2009-09-29 17:40:00 2009-09-29 17:42:00 2009-09-29 17:44:00 #Levels: 2009-09-29 17:40:00 2009-09-29 17:42:00 2009-09-29 17:44:00 sessionInfo() R version 2.9.2 Patched (2009-09-24 r50069) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics utils datasets grDevices methods base Vitalie. __ 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] Sampling procedure
If parsimony is needed, then define a 9-row matrix and send a randomized indexed version of Example to it: s-matrix(NA, nrow=9, ncol=length(Example)/9) s[,] - Example[sample(Example, length(Example) )] str(s) int [1:9, 1:87] 503 731 708 23 255 675 163 381 361 412 ... Or even: s-matrix(Example[ sample(Example, length(Example) )], nrow=9, ncol=length(Example)/9) -- David On Oct 15, 2009, at 11:22 AM, Bert Gunter wrote: If I understand what is wanted correctly, this can be a one-liner! -- think whole objects: splitup - function(x,n.groups) #split x into n.groups mutually exclusive sets { lx - length(x) if(n.groups = lx) stop(Number of groups greater than vector length) x - x[sample(lx,lx)] split(x,seq_len(n.groups)) } ## testit splitup(1:71,9) $`1` [1] 22 26 38 50 65 60 9 27 $`2` [1] 24 2 69 28 71 31 41 13 $`3` [1] 16 47 63 45 23 1 8 32 $`4` [1] 34 39 64 35 7 19 4 55 $`5` [1] 54 10 37 68 6 17 70 18 $`6` [1] 61 11 5 46 33 43 14 56 $`7` [1] 42 44 12 62 66 48 57 58 $`8` [1] 21 40 30 29 20 49 52 67 $`9` [1] 59 15 25 51 3 36 53 Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of David Winsemius Sent: Thursday, October 15, 2009 7:55 AM To: Marcio Resende Cc: r-help@r-project.org Subject: Re: [R] Sampling procedure On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote: I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example - matrix(c(1:783),ncol = 1) Example - matrix(c(1:783),ncol = 1) Grp1 - sample(Example, 87, replace=FALSE) Grp2 - sample(Example[-Grp1], 87, replace=FALSE) Grp3 - sample(Example[-c(Grp1, Grp2)], 87, replace=FALSE) # lather, rinse , repeat s1 - as.matrix(sample(Example,87, re = FALSE)) Example - Example[-s1] s2 - as.matrix(sample(Example,87, re = FALSE)) #however I don´t know how to remove the second group from the Example to continue sampling. #Don't mess up the original There is probably an easy and faster way to do this. Could anybody help me? Thanks -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Two way anova repeated measures and post hoc testing - several questions
Hi, I am fairly new to R and still trying to figure out how it all works, and I have run into a few issues. I apologize in advance if my questions are a bit basic, I'm also no statistics wizard, so part of my problem my be a more fundamental lack of knowledge in the field. I have a dataset that looks something like this: Week Subj Group Readout 01 A 352.2 11 A 366.6 21 A 377.3 31 A 389.8 41 A 392.5 02 B 344.7 12 B 360.9 . . . . So basically I have a number of subjects that are divided into different groups receiving different interventions/treatments. Observations on these subjects are made on 5 occasions (Week 0-4). I would like to see if there is difference between the treatment groups and if the observations that we are making change in the individual groups over time. According to my very limited statistics training that means that I would have to do a two-way anova with repeated measures because the same subjects are observed on the different weeks. Now in R I can do something like this: MyData$fWeek - factor(MyData$Week) #Convert week to factor m1 - aov(Readout ~ Group*fWeek + Error(Subj/fWeek), data=MyData) My first naive question is: Is the Error(...) term correct for the design that I describe? I am not quite sure if I understand the syntax correctly. In any case, it actually seems to work fine, but I can't figure out how to do post hoc testing on this. TukeyHSD does not work for the aovlist which is returned, so I am kind of stuck. Is there a simple way to do the post hoc test based on the aovlist? I have been reading various questions on the list and I think that I have understood that I should be using lme from the nlme package and this is where I run into some problems. As I understand it, the lme command that I would need would look something like this: m1 - lme(Readout ~ Group*fWeek,random=~1|Subj/fWeek, data=MyData) Now this actually fails with an error message like: Error in MEEM(object, conLin, control$niterEM) : Singularity in backsolve at level 0, block 1 The reason (I believe) is that I have some weeks where there are no observations for a specific group. In this case, one of the groups had a lot of drop-out and at Week 4, there are no subjects left in one of the groups and that seems to be causing the problem. I can get it to run by excluding the last week with something like: m1 - lme(Readout ~ Group*fWeek,random=~1|Subj/fWeek, data=MyData[which(MyData$Week 4), ]) My next question is: Is there another way around that? I would still like to run the analysis for the remaining groups on the last time point and I believe that it should somehow be included into the entire analysis. I have also managed to find a few postings with similar problems, but no real solutions, so anything helpful comments would be much appreciated. My final issue is how do I do the post hoc testing on the model. I understand (I think) that I should use the glht function from the multcomp package. For Instance, I could do something like: summary(glht(m1,linfct=c(GroupB:fWeek1 - GroupC:fWeek1 = 0,GroupB:fWeek2 - GroupC:fWeek2 = 0))) And that actually works fine. My problem is that Group A and fWeek 0 seems to have turned into the (intercept), so I can't write something like: summary(glht(m1,linfct=c(GroupB:fWeek0 - GroupB:fWeek1 = 0))) To check for changes between baseline and week 1 in Group B because I get the error message: Error in chrlinfct2matrix(linfct, names(beta)) : variable(s) GroupB:fWeek0 not found When I look at summary(m1) the error message makes sense, because (as I said) I think they are listed as the (intercept). However, that is a bit inconvenient and I was wondering if there is a different way to to so that I don't have that problem. How do you actually control what the intercept is? In my specific case, I don't think of Group A as baseline or vehicle or placebo treatment. I apologize for my long email. To sum up my questions: 1. Is my formulation of the Error(...) term or the value for the random variable in lme correct given the design that I have described? 2. Is there a way to do post hoc testing on the aovlist object that comes out of the anova with repested measures 3. Is there a way to make lme not fail when there are group/time combinations with no entries 4. How do you control what is the (intercept) in the model returned by the lme function and is there a way to still be able to refer to all groups and timepoints in there without referring to intercept? I would appreciate any help and comments and do feel free to educate me if I have got it all wrongit is quite likely. Thanks, Michael [[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,
Re: [R] Sampling procedure
... except the matrix approach doesn't work if the length of the vector is not exactly divisible by the number of groups. That's why I used split. Cheers, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, October 15, 2009 8:48 AM To: Bert Gunter Cc: 'Marcio Resende'; r-help@r-project.org Subject: Re: [R] Sampling procedure If parsimony is needed, then define a 9-row matrix and send a randomized indexed version of Example to it: s-matrix(NA, nrow=9, ncol=length(Example)/9) s[,] - Example[sample(Example, length(Example) )] str(s) int [1:9, 1:87] 503 731 708 23 255 675 163 381 361 412 ... Or even: s-matrix(Example[ sample(Example, length(Example) )], nrow=9, ncol=length(Example)/9) -- David On Oct 15, 2009, at 11:22 AM, Bert Gunter wrote: If I understand what is wanted correctly, this can be a one-liner! -- think whole objects: splitup - function(x,n.groups) #split x into n.groups mutually exclusive sets { lx - length(x) if(n.groups = lx) stop(Number of groups greater than vector length) x - x[sample(lx,lx)] split(x,seq_len(n.groups)) } ## testit splitup(1:71,9) $`1` [1] 22 26 38 50 65 60 9 27 $`2` [1] 24 2 69 28 71 31 41 13 $`3` [1] 16 47 63 45 23 1 8 32 $`4` [1] 34 39 64 35 7 19 4 55 $`5` [1] 54 10 37 68 6 17 70 18 $`6` [1] 61 11 5 46 33 43 14 56 $`7` [1] 42 44 12 62 66 48 57 58 $`8` [1] 21 40 30 29 20 49 52 67 $`9` [1] 59 15 25 51 3 36 53 Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of David Winsemius Sent: Thursday, October 15, 2009 7:55 AM To: Marcio Resende Cc: r-help@r-project.org Subject: Re: [R] Sampling procedure On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote: I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example - matrix(c(1:783),ncol = 1) Example - matrix(c(1:783),ncol = 1) Grp1 - sample(Example, 87, replace=FALSE) Grp2 - sample(Example[-Grp1], 87, replace=FALSE) Grp3 - sample(Example[-c(Grp1, Grp2)], 87, replace=FALSE) # lather, rinse , repeat s1 - as.matrix(sample(Example,87, re = FALSE)) Example - Example[-s1] s2 - as.matrix(sample(Example,87, re = FALSE)) #however I don´t know how to remove the second group from the Example to continue sampling. #Don't mess up the original There is probably an easy and faster way to do this. Could anybody help me? Thanks -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] ImageMagick not seen by movie3d function from rgl package
Hello R-users, I have downloaded and installed a binary version for Windows OS of ImageMagick (ImageMagick6.5.6-10-q16-windows-dll.exe), I have installed the rgl package and i've tried running the following example from ?movie3d() library(rgl) open3d() plot3d( cube3d(col=green) ) M - par3d(userMatrix) play3d( par3dinterp( userMatrix=list(M, rotate3d(M, pi/2, 1, 0, 0), rotate3d(M, pi/2, 0, 1, 0) ) ), duration=4 ) movie3d( spin3d(), duration=5 ) and then I get the following message: Writing movie050.png Error in movie3d(spin3d(), duration = 5) : ImageMagick not found which if I am correct means that R can not see ImageMagick (i have in the ImageMagick in the path variable: C:\Program Files\ImageMagick-6.5.6-Q16;;%GTK_BASEPATH%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\jEdit) I have found some earlier post with apparently the same problem, but no solution. Can anyone tell me what i am doing wrong? Thank you very much and have a great day ahead! sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] caTools_1.10 bitops_1.0-4.1 rgl_0.87 Rcmdr_1.5-3 car_1.2-16 scatterplot3d_0.3-28 [7] MASS_7.2-47 mgcv_1.5-5 lattice_0.17-25 foreign_0.8-36 loaded via a namespace (and not attached): [1] grid_2.9.1 nlme_3.1-92 tools_2.9.1 __ 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] Best way to get stock quotes
Don't know about preferred but I believe the QuantMod package has a command for getting them from Yahoo finance. - Mark On Wed, Oct 14, 2009 at 11:24 PM, keifer jonathan.keith.hagan...@gmail.com wrote: What is preferred/better, get.hit.quote, priceIts, or other? -- View this message in context: http://www.nabble.com/Best-way-to-get-stock-quotes-tp25903585p25903585.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.
Re: [R] Sampling procedure
OK, you're right. I thought it might be simple fix to increase the number of columns to accommodate, but the recycling conventions trips up that strategy. Thanks; David. On Oct 15, 2009, at 11:55 AM, Bert Gunter wrote: ... except the matrix approach doesn't work if the length of the vector is not exactly divisible by the number of groups. That's why I used split. Cheers, Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: Thursday, October 15, 2009 8:48 AM To: Bert Gunter Cc: 'Marcio Resende'; r-help@r-project.org Subject: Re: [R] Sampling procedure If parsimony is needed, then define a 9-row matrix and send a randomized indexed version of Example to it: s-matrix(NA, nrow=9, ncol=length(Example)/9) s[,] - Example[sample(Example, length(Example) )] str(s) int [1:9, 1:87] 503 731 708 23 255 675 163 381 361 412 ... Or even: s-matrix(Example[ sample(Example, length(Example) )], nrow=9, ncol=length(Example)/9) -- David On Oct 15, 2009, at 11:22 AM, Bert Gunter wrote: If I understand what is wanted correctly, this can be a one-liner! -- think whole objects: splitup - function(x,n.groups) #split x into n.groups mutually exclusive sets { lx - length(x) if(n.groups = lx) stop(Number of groups greater than vector length) x - x[sample(lx,lx)] split(x,seq_len(n.groups)) } ## testit splitup(1:71,9) $`1` [1] 22 26 38 50 65 60 9 27 $`2` [1] 24 2 69 28 71 31 41 13 $`3` [1] 16 47 63 45 23 1 8 32 $`4` [1] 34 39 64 35 7 19 4 55 $`5` [1] 54 10 37 68 6 17 70 18 $`6` [1] 61 11 5 46 33 43 14 56 $`7` [1] 42 44 12 62 66 48 57 58 $`8` [1] 21 40 30 29 20 49 52 67 $`9` [1] 59 15 25 51 3 36 53 Cheers, Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of David Winsemius Sent: Thursday, October 15, 2009 7:55 AM To: Marcio Resende Cc: r-help@r-project.org Subject: Re: [R] Sampling procedure On Oct 15, 2009, at 10:19 AM, Marcio Resende wrote: I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example - matrix(c(1:783),ncol = 1) Example - matrix(c(1:783),ncol = 1) Grp1 - sample(Example, 87, replace=FALSE) Grp2 - sample(Example[-Grp1], 87, replace=FALSE) Grp3 - sample(Example[-c(Grp1, Grp2)], 87, replace=FALSE) # lather, rinse , repeat s1 - as.matrix(sample(Example,87, re = FALSE)) Example - Example[-s1] s2 - as.matrix(sample(Example,87, re = FALSE)) #however I don´t know how to remove the second group from the Example to continue sampling. #Don't mess up the original There is probably an easy and faster way to do this. Could anybody help me? Thanks -- David Winsemius, MD Heritage Laboratories West Hartford, CT David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Subset returning unexpected result
77eb52c6dd32ba4d87471dcd70c8d70001f11...@na-pa-vbe03.na.tibco.com Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Dear Bill and all=2C Yep you were right - for some strange reason (I'm not sure how...)=2C the l= atitude data were of class 'character' instead of 'numeric'. I've put that = right and that seems to have fixed it! Many thanks for your help=2C Steve =20 __ 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] Subset returning unexpected result
It would be useful to also post the 'str(int1901)' so that we could see the structure of the dataframe. Is Latitude by chance a 'factor'? You could also put a subset with the data by doing: dput(int1901) On Thu, Oct 15, 2009 at 11:39 AM, Steve Murray smurray...@hotmail.com wrote: Dear all, I am attempting to subset a data frame based on a range of latitude values. I want to extract the values of 'interception' where latitude ranges between 50 and 60. I am doing this using the following code, yet it doesn't return the results I expected: test - subset(int1901, Latitude=50 Latitude 60, select=c(Latitude, Interception)) head(test) Latitude Interception 2 6.25 0.04725863 3 6.75 67.02455139 82 50.75 51.74784088 83 51.25 57.04327774 84 51.75 51.51020432 85 52.25 53.30662537 As you can see, latitude values outside the 50 to 60 range have been retained (e.g. the top two rows of 'test'). Why is this, and how can I ensure that I subset the data as initially intended? Many thanks for any help offered, Steve __ 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 Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] Subset returning unexpected result
On Oct 15, 2009, at 11:39 AM, Steve Murray wrote: Dear all, I am attempting to subset a data frame based on a range of latitude values. I want to extract the values of 'interception' where latitude ranges between 50 and 60. I am doing this using the following code, yet it doesn't return the results I expected: test - subset(int1901, Latitude=50 Latitude 60, select=c(Latitude, Interception)) head(test) Latitude Interception 2 6.25 0.04725863 3 6.75 67.02455139 8250.75 51.74784088 8351.25 57.04327774 8451.75 51.51020432 8552.25 53.30662537 As you can see, latitude values outside the 50 to 60 range have been retained (e.g. the top two rows of 'test'). Why is this, and how can I ensure that I subset the data as initially intended? What does str(int1901) show to be the type for Latitude? (I'm guessing it's a factor.) -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Clustering for Ordinal data
On Wednesday 14 October 2009, Paul Evans wrote: Hi, I just wanted to check whether there is a clustering package available for ordinal data. My data looks something like: #1 #2 #3 #4. A B C D... D B C A... D C A A... where each column represents a sample, and each row some ordinal values. I would like to cluster such that similar samples appear together. thanks! Hi, See the 'cluster' package. You will need to select a distance metric that can deal with factors. The 'Gower' metric is one that is commonly used. Cheers, Dylan -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341 __ 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] Subset returning unexpected result
fa3c85ac-06ab-4635-9642-8909552c0...@comcast.net Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Bill=2C It seems to be 'character' - odd...! str(int1901$Latitude) =A0chr [1:61537] 5.75 6.25 6.75 7.25 7.75 8.25 ... Thanks again=2C Steve What does str(int1901) show to be the type for Latitude? (I'm guessing it's a factor.) -- David Winsemius=2C MD Heritage Laboratories West Hartford=2C CT =20 __ 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] Announcement: New R book--50% off today only
I believe this post violates the standards of this list. It's an advertisement. -- Bert Gunter -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steven Hong Sent: Wednesday, October 14, 2009 11:45 AM To: r-help@r-project.org Subject: [R] Announcement: New R book--50% off today only Hi all, This is Steven with Manning Publications. I wanted to announce the launch of a new R book: R in Action by Rob Kabacoff. Rob was recently interviewed for this piece on Teradata about the growth of R into new fields and the future of R. The book gives thorough coverage of the R environment with dozens of practical examples of its uses. We're doing a one day 50% off deal on the book using the code twtr1014. The deal is exclusive to the Manning site. The code was announced for our Twitter followers, but I thought I'd announce it here as well. The code expires on October 15. R in Action is currently available through the Manning Early Access Program. Books in the Manning Early Access Program (MEAP) work on a subscription-based model. You receive a download link to the manuscript as it is now in development. When new chapters are added to the MEAP, you get a new download link with the new version of the manuscript. This happens all the way up until and including the final completed ebook. Best regards, Steven Hong Marketing Coordinator Manning Publications www.manning.com === Skype: stevenhong02 Twitter: ManningBooks [[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] changing a matrix from class data.frame to class dist
On Oct 15, 2009, at 11:34 AM, Maxime Pauwels wrote: Dear, I have a data frame object (FSTc) which is in fact a matrix of class data.frame Not sure that is possible (in R terminology anyway.). Dataframes are lists. but created from a txt file using the command FSTc-read.table(FSTcmatrix.txt, header=T) I would like to transform it in a distance matrix of class dist to use it with the ade4 package. I'm quite sure this is a simple operation but i just don't have the commands. ?dist #which points to ?as.dist # which is a coercion function -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] ImageMagick not seen by movie3d function from rgl package
On 10/15/2009 12:01 PM, eugen pircalabelu wrote: Hello R-users, I have downloaded and installed a binary version for Windows OS of ImageMagick (ImageMagick6.5.6-10-q16-windows-dll.exe), I have installed the rgl package and i've tried running the following example from ?movie3d() library(rgl) open3d() plot3d( cube3d(col=green) ) M - par3d(userMatrix) play3d( par3dinterp( userMatrix=list(M, rotate3d(M, pi/2, 1, 0, 0), rotate3d(M, pi/2, 0, 1, 0) ) ), duration=4 ) movie3d( spin3d(), duration=5 ) and then I get the following message: Writing movie050.png Error in movie3d(spin3d(), duration = 5) : ImageMagick not found which if I am correct means that R can not see ImageMagick (i have in the ImageMagick in the path variable: C:\Program Files\ImageMagick-6.5.6-Q16;;%GTK_BASEPATH%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\jEdit) I have found some earlier post with apparently the same problem, but no solution. Can anyone tell me what i am doing wrong? Likely it's not really in your path. Use Sys.getenv(PATH) to see what R sees as your path. It certainly won't look like what you just posted: those % variables will be expanded, for instance. If C:\Program Files\ImageMagick-6.5.6-Q16 is on your real path, then go to that folder, and make sure the executable convert.exe is there. That's what rgl is looking for. Duncan Murdoch Thank you very much and have a great day ahead! sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] caTools_1.10 bitops_1.0-4.1 rgl_0.87 Rcmdr_1.5-3 car_1.2-16 scatterplot3d_0.3-28 [7] MASS_7.2-47 mgcv_1.5-5 lattice_0.17-25 foreign_0.8-36 loaded via a namespace (and not attached): [1] grid_2.9.1 nlme_3.1-92 tools_2.9.1 __ 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] plotting/examining residuals of a mixed generalised linear model
Thanks Ben, that was what I was looking for. I look forward to the lmer book (Pinheiro and Bates 2000 is very good and has already been helpful) -- View this message in context: http://www.nabble.com/plotting-examining-residuals-of-a-mixed-generalised-linear-model-tp25905522p25911559.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] Announcement: New R book--50% off today only
Bert, I'm sorry if it violates the terms. I was careful to read through the posting guidelines here. I was initially thinking of posting to the R- announce list, but the description says that that list is for major announcements. So I saw that the R-help list is for discussion about problems and solutions using R, announcements (not covered by 'R- announce' or 'R-packages') and thought this would be the appropriate list. Being that the book is about R, I thought it would be informative to the mail list. Sorry if it inconveniences you and if it is indeed a violation of the terms, I apologize. -steven On Oct 15, 2009, at 8:32 AM, Bert Gunter wrote: I believe this post violates the standards of this list. It's an advertisement. -- Bert Gunter -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Steven Hong Sent: Wednesday, October 14, 2009 11:45 AM To: r-help@r-project.org Subject: [R] Announcement: New R book--50% off today only Hi all, This is Steven with Manning Publications. I wanted to announce the launch of a new R book: R in Action by Rob Kabacoff. Rob was recently interviewed for this piece on Teradata about the growth of R into new fields and the future of R. The book gives thorough coverage of the R environment with dozens of practical examples of its uses. We're doing a one day 50% off deal on the book using the code twtr1014. The deal is exclusive to the Manning site. The code was announced for our Twitter followers, but I thought I'd announce it here as well. The code expires on October 15. R in Action is currently available through the Manning Early Access Program. Books in the Manning Early Access Program (MEAP) work on a subscription-based model. You receive a download link to the manuscript as it is now in development. When new chapters are added to the MEAP, you get a new download link with the new version of the manuscript. This happens all the way up until and including the final completed ebook. Best regards, Steven Hong Marketing Coordinator Manning Publications www.manning.com === Skype: stevenhong02 Twitter: ManningBooks [[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] calculating p-values by row for data frames
Hello R-users, I am looking for an elegant way to calculate p-values for each row of a data frame. My situation is as follows: I have a gene expression results from a microarray with 64 samples looking at 25626 genes. The results are in a data frame with the dimensions 64 by 25626 I want to create a volcano plot of difference of means vs. –log(10) of the p-values, comparing normal samples to abnormal samples. The results of both type of samples are all in my data frame. Now, I have found a way to calculate the p-value using a “for (i in 1:25626)” loop (see below): df.normal #dataframe, which only contains the normal samples df.samples #dataframe, which only contains abnormal samples DM=rowMeans(df.normal)-rowMeans(df.samples) #gives me a dataframe with the difference of means PV=array(1,c(25626,1)) for (i in 1:25626){ VL=t.test(matrix.b[i,],matrix.a[i,]) V=as.numeric(VL[3]) V=-log10(V) PV[i,1]=V} plot(DM, PV, main=title,xlab=x.lab, ylab=-log(10) P-Values,pch=20)} It takes around 3-5 minutes to generate the volcano plot this way. I will be running arrays which will look at 2.2 million sites this approach will then take way too long. I was wondering if there is a more elegant way to calculate the p-values for an array/fataframe/matrix in a row-by row fashion, which is similar to “rowMeans”. I thought writing a function to get the p-value and then using apply(x,1,function) would be the best. I have the function which will give me the p-value p.value = function (x,y){ PV=as.numeric(t.test(x,y)[3]) } and I can get a result if I test it only on one row (below is 6 by 10 data frame example of my original data) RRR X259863X267862 X267906X300875 X300877 X300878 MSPI0406S0183 -3.2257205 -3.2248899 2.85590082 -2.6293602 -3.5054348 -2.62817269 MSPI0406S0238 -2.6661903 -3.1135020 2.17073881 -3.2357307 -2.3309775 -1.76078452 MSPI0406S0239 -1.7636439 -0.6702877 0.19471126 -0.7397132 -1.4332662 -0.24822470 MSPI0406S0300 0.6471381 -0.2638928 -0.61876054 -0.9180127 0.2539848 -0.63122203 MSPI0406S0301 0.9207208 0.2164267 -0.33238846 -1.1450717 -0.2935584 -1.01659802 MSPI0406S0321 -0.4073272 -0.2852402 -0.08085746 -0.4109428 -0.2185432 -0.39736137 MSPI0406S0352 -0.7074175 -0.6987548 -1.22004647 -0.8570551 -0.5083861 -0.09267928 MSPI0406S0353 -0.2745682 0.3012990 -0.64787221 -0.5654195 0.4265007 -0.65963404 MSPI0406S0354 -1.1858394 -1.4388609 -0.07329722 -2.0010785 -1.3245696 -1.43216984 MSPI0406S0360 -1.4599809 -1.4929059 0.63453235 -1.1476760 -1.5849922 -1.03187399 zz=p.value(RRR[1,1:3],RRR[1,4:6]) zz $p.value [1] 0.485727 but I cannot do this row by row using apply xxx=apply(RRR,1,p.value(RRR[,1:3],RRR[,4:6])) Error in match.fun(FUN) : 'p.value(RRR[, 1:3], RRR[, 4:6])' is not a function, character or symbol Does anyone have any suggestions? Thanks in advance Christoph Heuck Albert Einstein College of Medicine __ 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] QQ-Plot using GAP but no 95% Confidence Bands...
Hi everyone, I have recently installed the gap library in order to create QQ plots. The library works well but was wondering if anyone knew how to create the 95% confidence bands at the top of the QQ plot? Many thanks. Sam. -- View this message in context: http://www.nabble.com/QQ-Plot-using-GAP-but-no-95--Confidence-Bands...-tp25911248p25911248.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] currency conversion function?
Hi Liviu, Try this function now: foo - function(from, to, date){ url - http://www.oanda.com/convert/classic?script=..%2Fconvert%2Fclassiclanguage=envalue=1; params - sprintf(%sdate=%sexch=%sexch2=margin_fixed=0expr=%sexpr2=SUBMIT=Convert+Nowlang=endate_fmt=us, url, format(as.Date(date), %m/%d/%y), to, from) Lines - readLines(params) value - gsub(.*(.+[0-9]\\.[0-9]+).*, \\1, grep(nl, grep(from, grep(to, Lines, value = TRUE), value = TRUE), value = TRUE)) as.numeric(value) } foo('EUR', 'RUB', '2009-10-15') foo('EUR', 'USD', '2009-10-15') On Wed, Oct 14, 2009 at 1:45 PM, Liviu Andronic landronim...@gmail.com wrote: Hello On 10/14/09, Henrique Dallazuanna www...@gmail.com wrote: foo('BRL', 'USD', '2009-10-14') Nice function, thank you. Two issues, though: - it seems to provide reverse output. Example: ## how many dollars do you get from one euro? foo('EUR', 'USD', '2009-10-14') [1] 0.67544 ## however, the equivalent of 1 Euro would be .. 1/foo('EUR', 'USD', '2009-10-14') [1] 1.4805 ## .. dollars ## 1 Euro = 1.48051 US Dollar ## taken from the on-line converter The dirty hack is to use 1/as.numeric(value) as a return value. For describing the next issue I will use the improved version of the function. - second issue, for weaker currencies (that is, with more digits) the reported value is not necessarily correct. Example: ## fine foo('EUR', 'RUB', '2009-10-14') [1] 43.745 ## fine 1/foo('EUR', 'RUB', '2009-10-14') [1] 0.02286 ## wrong foo('RUB', 'EUR', '2009-10-14') [1] 0.26878 ## taken from the on-line converter ## 1 Euro = 43.75188 Russian Rouble ## 1 Russian Rouble (RUB) = 0.02286 Euro (EUR) I am not sure on how to fix this one. Thank you Liviu -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ 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] ImageMagick not seen by movie3d function from rgl package --SOLVED
Hello, Thank you Duncan! Actually Sys.getenv(PATH) said the same thing: ImageMagick is in my path (and convert.exe is where it is supposed to be), but after i opened R (to see the actual path in R, as you said), loaded rgl, and run again the example, it worked. I guess that after the software installation, I should have loaded rgl package again in R. So now it works! Thank you once again! - Original Message From: Duncan Murdoch murd...@stats.uwo.ca To: eugen pircalabelu eugen_pircalab...@yahoo.com Cc: R-help r-h...@stat.math.ethz.ch Sent: Thu, October 15, 2009 6:31:58 PM Subject: Re: [R] ImageMagick not seen by movie3d function from rgl package On 10/15/2009 12:01 PM, eugen pircalabelu wrote: Hello R-users, I have downloaded and installed a binary version for Windows OS of ImageMagick (ImageMagick6.5.6-10-q16-windows-dll.exe), I have installed the rgl package and i've tried running the following example from ?movie3d() library(rgl) open3d() plot3d( cube3d(col=green) ) M - par3d(userMatrix) play3d( par3dinterp( userMatrix=list(M, rotate3d(M, pi/2, 1, 0, 0), rotate3d(M, pi/2, 0, 1, 0) ) ), duration=4 ) movie3d( spin3d(), duration=5 ) and then I get the following message: Writing movie050.png Error in movie3d(spin3d(), duration = 5) : ImageMagick not found which if I am correct means that R can not see ImageMagick (i have in the ImageMagick in the path variable: C:\Program Files\ImageMagick-6.5.6-Q16;;%GTK_BASEPATH%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\jEdit) I have found some earlier post with apparently the same problem, but no solution. Can anyone tell me what i am doing wrong? Likely it's not really in your path. Use Sys.getenv(PATH) to see what R sees as your path. It certainly won't look like what you just posted: those % variables will be expanded, for instance. If C:\Program Files\ImageMagick-6.5.6-Q16 is on your real path, then go to that folder, and make sure the executable convert.exe is there. That's what rgl is looking for. Duncan Murdoch Thank you very much and have a great day ahead! sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] caTools_1.10 bitops_1.0-4.1 rgl_0.87 Rcmdr_1.5-3 car_1.2-16 scatterplot3d_0.3-28 [7] MASS_7.2-47 mgcv_1.5-5 lattice_0.17-25 foreign_0.8-36 loaded via a namespace (and not attached): [1] grid_2.9.1 nlme_3.1-92 tools_2.9.1 __ 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] ImageMagick not seen by movie3d function from rgl package --SOLVED
On 10/15/2009 1:01 PM, eugen pircalabelu wrote: Hello, Thank you Duncan! Actually Sys.getenv(PATH) said the same thing: ImageMagick is in my path (and convert.exe is where it is supposed to be), but after i opened R (to see the actual path in R, as you said), loaded rgl, and run again the example, it worked. I guess that after the software installation, I should have loaded rgl package again in R. So now it works! Thank you once again! Yes, R is given a copy of the PATH when it starts, and updates to the PATH are not seen until you restart it. Duncan Murdoch - Original Message From: Duncan Murdoch murd...@stats.uwo.ca To: eugen pircalabelu eugen_pircalab...@yahoo.com Cc: R-help r-h...@stat.math.ethz.ch Sent: Thu, October 15, 2009 6:31:58 PM Subject: Re: [R] ImageMagick not seen by movie3d function from rgl package On 10/15/2009 12:01 PM, eugen pircalabelu wrote: Hello R-users, I have downloaded and installed a binary version for Windows OS of ImageMagick (ImageMagick6.5.6-10-q16-windows-dll.exe), I have installed the rgl package and i've tried running the following example from ?movie3d() library(rgl) open3d() plot3d( cube3d(col=green) ) M - par3d(userMatrix) play3d( par3dinterp( userMatrix=list(M, rotate3d(M, pi/2, 1, 0, 0), rotate3d(M, pi/2, 0, 1, 0) ) ), duration=4 ) movie3d( spin3d(), duration=5 ) and then I get the following message: Writing movie050.png Error in movie3d(spin3d(), duration = 5) : ImageMagick not found which if I am correct means that R can not see ImageMagick (i have in the ImageMagick in the path variable: C:\Program Files\ImageMagick-6.5.6-Q16;;%GTK_BASEPATH%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\jEdit) I have found some earlier post with apparently the same problem, but no solution. Can anyone tell me what i am doing wrong? Likely it's not really in your path. Use Sys.getenv(PATH) to see what R sees as your path. It certainly won't look like what you just posted: those % variables will be expanded, for instance. If C:\Program Files\ImageMagick-6.5.6-Q16 is on your real path, then go to that folder, and make sure the executable convert.exe is there. That's what rgl is looking for. Duncan Murdoch Thank you very much and have a great day ahead! sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] tcltk stats graphics grDevices utils datasets methods base other attached packages: [1] caTools_1.10 bitops_1.0-4.1 rgl_0.87 Rcmdr_1.5-3 car_1.2-16 scatterplot3d_0.3-28 [7] MASS_7.2-47 mgcv_1.5-5 lattice_0.17-25 foreign_0.8-36 loaded via a namespace (and not attached): [1] grid_2.9.1 nlme_3.1-92 tools_2.9.1 __ 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-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] help: combine multiple 'pairs plots'
What are you trying to accomplish with this? Pairs sets up the device to make the multiple plots and overrides previous splitting. If you tell us what you want to accomplish, then maybe we can tell you a different way to get the result you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Jesse Poland Sent: Thursday, October 15, 2009 9:25 AM To: joris meys Cc: r-help@r-project.org Subject: Re: [R] help: combine multiple 'pairs plots' Thanks. However, for each function [ par(mfrow=..); layout(); and split.screen()] the pairs() graphic function creates an new graphic rather than combining into a single graphic. joris meys wrote: Don't know if it will work, but did you try ?layout ? Otherwise you can take a look at ?split.screen too. Cheers Joris On Thu, Oct 15, 2009 at 2:39 PM, Jesse Poland jap...@cornell.edu wrote: I would like to combine multiple pairs plots (each one being a matrix of correlation plots) into a single graphic. I have tried the par() function, which works well to combine several simple graphs. However, the pairs() graph seems to override the par() function and produce an new plot, rather than combining the plots into a single graphic. Thanks, Jesse __ 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-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] currency conversion function?
OandA now limits fills to 500 days (as indicated by the error). You can of course just request 500 days at a time. The function itself will not automatically do that as that would be clearly abusing the rules that OandA have established. Of course what you do with your own code is your own business... getFX(EUR/USD,from=2009-04-01) [1] EURUSD head(EURUSD) EUR.USD 2009-04-01 1.3277 2009-04-02 1.3227 2009-04-03 1. 2009-04-04 1.3443 2009-04-05 1.3490 2009-04-06 1.3491 If you are looking for additional FX data, the FRED archive (St. Louis Fed) is very good as well... http://research.stlouisfed.org/fred2/categories/94 getSymbols(DEXUSEU, src=FRED) [1] DEXUSEU head(DEXUSEU) DEXUSEU 1999-01-04 1.1812 1999-01-05 1.1760 1999-01-06 1.1636 1999-01-07 1.1672 1999-01-08 1.1554 1999-01-11 1.1534 Keep in mind that FX data isn't coming from a centralized exchange, so all vendors will be different. ?getFX ?getSymbols.FRED HTH, Jeff -- View this message in context: http://www.nabble.com/currency-conversion-function--tp25888083p25913241.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] help: combine multiple 'pairs plots'
Jesse Poland wrote: I would like to combine multiple pairs plots (each one being a matrix of correlation plots) into a single graphic. I have tried the par() function, which works well to combine several simple graphs. However, the pairs() graph seems to override the par() function and produce an new plot, rather than combining the plots into a single graphic. This looks like a job for splom in lattice. library(lattice) tmp - cbind(environmental, group=rep(1:2, length=111)) splom( ~ tmp[,1:4] | tmp$group) __ 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] Setting random effects within a category using nlme
Hello, I will start out with the caveat that I'm not a statistician by training, but have a fairly decent understanding of probability and likelihood. Nevertheless, I'm trying to fit a nonlinear model to a dataset which has two main factors using nlme. Within the dataset there are two Type categories and four Tissue categories, thus giving me 8 datasets in total. The dataset is in a groupedData object with formula= Count ~ Time|Type/Tissue and there are three basic model parameters that I am trying to fit: T0, aN, and aL. Calling nlsList gives -- nlsList(Count ~ quad.PBMC.model(aL, aN, T0), data = tissueData, start = list(T0 = 1000, aN = exp(-2), aL = exp(-2))) Call: Model: Count ~ quad.PBMC.model(aL, aN, T0) | Type/Tissue Data: tissueData Coefficients: T0 aN aL Naive/CLN1530.0088 0.26508876 0.04730525 Naive/ILN 296.4755 0.09270158 0.09542535 Naive/IngLN 828.1406 0.50799864 0.12500593 Naive/MLN 487.6856 0.16565269 0.10385125 Memory/CLN 3567.2132 0.05656948 0.07753467 Memory/ILN708.1642 0.01264033 0.10018441 Memory/IngLN 2114.1868 0.05298126 0.12795589 Memory/MLN 1050.0811 0.02277018 0.13560749 Degrees of freedom: 96 total; 72 residual Residual standard error: 271.4194 - I find that T0 varies greatly with each treatment, so I'm going to leave that alone for now. However, aN and aL values don't seem to vary w/in a Type or between Types. As a result, I would like to fit two mixed effects models. The first model assumes that aN and aL are from the same population, independent of Type. I believe that this is doing what I want, -- model1 = nlme(Count ~ quad.PBMC.model(aL, aN, T0), data = tissueData, start = list( fixed = c(rep(1000, 8), -2, -2) ), fixed = list(T0 ~ TypeTissue-1, aL ~ 1, aN ~ 1), random = aL + aN ~ 1|Tissue ) Nonlinear mixed-effects model fit by maximum likelihood Model: Count ~ quad.PBMC.model(aL, aN, T0) Data: tissueData Log-likelihood: -669.9258 Fixed: list(T0 ~ TypeTissue - 1, aL ~ 1, aN ~ 1) T0.TypeTissueMemory/CLN T0.TypeTissueMemory/ILN T0.TypeTissueMemory/IngLN 3517.767851692.356073 2058.228897 T0.TypeTissueMemory/MLNT0.TypeTissueNaive/CLNT0.TypeTissueNaive/ILN 998.151121 1677.199160301.686695 T0.TypeTissueNaive/IngLNT0.TypeTissueNaive/MLNaL 841.100309496.307552 -2.409191 aN -3.695229 Random effects: Formula: list(aL ~ 1, aN ~ 1) Level: Tissue Structure: General positive-definite, Log-Cholesky parametrization StdDev Corr aL 2.148064e-01 aL aN 4.548214e-04 -0.001 Residual 2.544745e+02 Number of Observations: 96 Number of Groups: 4 -- Note that I do not know how to get a separate T0 fit for each Type/Tissue, so I have created a column TypeTissue that has a unique designator for each Type/Tissue combination. Nevertheless, I *think* this is doing what I want. Given my limited stats training, I also like the fact that the Corr b/w aL and aN is very low. Moving on, the second model I would like to fit assumes that the population of aN and aL values across the set of Tissues differ between Types. I have tried a number of different syntaxes, but I can't seem to get the output I was expecting. For example, if I run -- model2 = nlme(Count ~ quad.PBMC.model(aL, aN, T0), + data = tissueData, + start = list( fixed = c(rep(1000, 8),rep(-2, 2), rep(-2, 2) )), + fixed = list(T0 ~ TypeTissue-1, aL ~ Type-1, aN ~ Type-1), + random = aL + aN ~ 1|Tissue + ) Nonlinear mixed-effects model fit by maximum likelihood Model: Count ~ quad.PBMC.model(aL, aN, T0), Data: tissueData Log-likelihood: -665.1197 Fixed: list(T0 ~ TypeTissue - 1, aL ~ Type - 1, aN ~ Type - 1) T0.TypeTissueMemory/CLN T0.TypeTissueMemory/ILN T0.TypeTissueMemory/IngLN 3587.056207711.544775 2089.597686 T0.TypeTissueMemory/MLNT0.TypeTissueNaive/CLNT0.TypeTissueNaive/ILN 1027.412736 1554.219211271.100935 T0.TypeTissueNaive/IngLNT0.TypeTissueNaive/MLN aL.TypeNaive 782.986653460.000116 -2.698370 aL.TypeMemory aN.TypeNaive aN.TypeMemory -2.253364 -1.718506 -3.318075 Random effects: Formula: list(aL ~ 1, aN ~ 1) Level: Tissue Structure: General positive-definite, Log-Cholesky parametrization StdDev Corr aL.(Intercept) 0.1997321 aL.(I)
Re: [R] SPSS long variable names
The problem is the limit of 8 characters long on variable names.[in read.spss??] I just created a file in SPSS 17 and saved it in standard format (.sav) The file had four unique variable NAMES which were much longer than 8 characters (although not 64). I entered two rows of data and saved the file again. The variable view in SPSS looked like the following for the 4 variables I created. (unique in the first postition after the first 9) a12345678901234567890987654321098765432011 Numeric 8 2 a1234567890 None None 14 Right Scale a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 Right Scale a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 14 Left Nominal a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 14 Right Scale I now started R and used read.spss() from the foreign package using the following code The data frame I read in seemed to reflect the original file with respect to column names: library(foreign) c=read.spss(file.choose(),to.data.frame=TRUE) c a12345678901234567890987654321098765432011 a1234567899123456789098765432109876543201 a1234567898123456789098765432109876543201 1 33.3 13452825600 a cat 2 22.2 1346328 dog a1234567897123456789098765432109876543201 1 32165 2 321654987 It appears these long variable names read in just fine. Thus, I would ask caveman whether the problem is really an R problem at all, or is it a problem with PSPP writing (in which case this would be the wrong list to be discussing it on)? R __ 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] Proper syntax for using varConstPower in nlme
Hello, Excuse me for posting two questions in one day, but I figured it would be better to ask my questions in separate emails. I will again give the caveat that I'm not a statistician by training, but have a fairly decent understanding of probability and likelihood. As before, I'm trying to fit a nonlinear model to a dataset which has two main factors using nlme. Within the dataset there are two Type categories and four Tissue categories, thus giving me 8 datasets in total. The dataset is in a groupedData object with formula= Count ~ Time|Type/Tissue and there are three basic model parameters that I am trying to fit: T0, aN, and aL. Calling nlsList gives -- nlsList(Count ~ quad.PBMC.model(aL, aN, T0), data = tissueData, start = list(T0 = 1000, aN = exp(-2), aL = exp(-2))) Call: Model: Count ~ quad.PBMC.model(aL, aN, T0) | Type/Tissue Data: tissueData Coefficients: T0 aN aL Naive/CLN1530.0088 0.26508876 0.04730525 . . . Memory/IngLN 2114.1868 0.05298126 0.12795589 Memory/MLN 1050.0811 0.02277018 0.13560749 Degrees of freedom: 96 total; 72 residual Residual standard error: 271.4194 - I find that T0 varies greatly with each treatment, so I'm going to leave that alone for now. However, aN and aL values don't seem to vary w/in a Type or between Types. As a result, I would like a mixed effects model using nlme. Further, looking at the residuals, I find that they are heteroscedastic. As a result, I would like to try and model the variance in the data using varConstPowerFun within nlme. I've been trying to understand how to use this option by reading Pinheiro and Bates's book on mixed effects models. Based on this, I've tried using the syntax, - nlme(Count ~ quad.PBMC.model(aL, aN, T0), + data = tissueData, + weights = varConstPower(form =~ Count), + start = list( fixed = c(rep(1000, 8), -2, -2) ), + fixed = list(T0 ~ TypeTissue-1, aL ~ 1, aN ~ 1), + random = aL + aN ~ 1|Tissue + ) Error in MEestimate(nlmeSt, grpShrunk) : Singularity in backsolve at level 0, block 1 - The above command clearly this doesn't work, but if I comment out the weights = ... line, it executes with no problem. I'd greatly appreciate any guidance on how to properly set up varConstPower. Sincerely, Mike - Department of Ecology Evolutionary Biology 569 Dabney Hall University of Tennessee Knoxville, TN 37996-1610 phone:(865) 974-6453 fax: (865) 974-6042 web: http://eeb.bio.utk.edu/gilchrist.asp __ 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] Problems with rJava and tm packages
I am looking to do some text analysis using R and have run into some issues with some of the packages. Im not sure if its my goofy Vista OS or what but using R 2.8.1 i s relatively successful loading the text but the rJava package was messed up somehow: library(tm) library(rJava) Error in if (!nchar(javahome)) stop(JAVA_HOME is not set and could not be determined from the registry) : argument is of length zero In addition: Warning message: package 'rJava' was built under R version 2.9.1 Error : .onLoad failed in 'loadNamespace' for 'rJava' Error: package/namespace load failed for 'rJava' #Set documents directory DIR - G:/TextSearch/Speeches #Load corpus speech - Corpus(DirSource(DIR), readerControl = list(reader = readPlain, + language = en_US, load = TRUE)) #Remove stopwords speech - tmMap(speech, stripWhitespace) speech A corpus with 2 text documents tdm-TermDocumentMatrix(speech) Error in if (!nchar(javahome)) stop(JAVA_HOME is not set and could not be determined from the registry) : argument is of length zero Error: .onLoad failed in 'loadNamespace' for 'rJava' So the initial question is whats going on with the rJava package? I get the same error when i try and load the package and then when i try and utilize a function from the package. I tried installing 2.9.2 and ran into more problems when running the lines: utils:::menuInstallPkgs() Warning: package 'tm' is in use and will not be installed speech - tmMap(speech, stripWhitespace) Error: could not find function tmMap the package is installed correctly but its not able to pick it up in this version of R. Again, im not sure if its somehting with Vista or what. Thanks guys and gals Cheers, JR -- View this message in context: http://www.nabble.com/Problems-with-rJava-and-tm-packages-tp25913472p25913472.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] Warning messages: Reached total allocation of 1023Mb: see help(memory.size)
Hi there, I run the following code in R and got the warning like that, how can I change the memory.size? Or anything else? Thanks a lot! Faye temp-apply(Idd4.perms$permstats[-stratum1,], + 2,sort) Error: cannot allocate vector of size 47.5 Mb In addition: Warning messages: 1: In apply(Idd4.perms$permstats[-stratum1, ], 2, sort) : Reached total allocation of 1023Mb: see help(memory.size) 2: In apply(Idd4.perms$permstats[-stratum1, ], 2, sort) : Reached total allocation of 1023Mb: see help(memory.size) 3: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) 4: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) 5: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) 6: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) -- View this message in context: http://www.nabble.com/Warning-messages%3A---Reached-total-allocation-of-1023Mb%3A-see-help%28memory.size%29-tp25912413p25912413.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] SPSS long variable names
Impressive! PSPP produces the sav fine. The sav file produced by the PSPP is seen by SPSS (16) with the long names. I attach my sav produced by the PSPP. And I start to suspect my foreign package version: I am using 0.8.26-1 from the r-cran-foreign a Ubuntu 8.10 package. Can you tell me your version? I am updating mine. Thanks guys. Caveman On Thu, Oct 15, 2009 at 9:02 PM, Robert Baer rb...@atsu.edu wrote: The problem is the limit of 8 characters long on variable names.[in read.spss??] I just created a file in SPSS 17 and saved it in standard format (.sav) The file had four unique variable NAMES which were much longer than 8 characters (although not 64). I entered two rows of data and saved the file again. The variable view in SPSS looked like the following for the 4 variables I created. (unique in the first postition after the first 9) a12345678901234567890987654321098765432011 Numeric 8 2 a1234567890 None None 14 Right Scale a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 Right Scale a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 14 Left Nominal a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 14 Right Scale I now started R and used read.spss() from the foreign package using the following code The data frame I read in seemed to reflect the original file with respect to column names: library(foreign) c=read.spss(file.choose(),to.data.frame=TRUE) c a12345678901234567890987654321098765432011 a1234567899123456789098765432109876543201 a1234567898123456789098765432109876543201 1 33.3 13452825600 a cat 2 22.2 1346328 dog a1234567897123456789098765432109876543201 1 32165 2 321654987 It appears these long variable names read in just fine. Thus, I would ask caveman whether the problem is really an R problem at all, or is it a problem with PSPP writing (in which case this would be the wrong list to be discussing it on)? R __ 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] Warning messages: Reached total allocation of 1023Mb: see help(memory.size)
Hi, On Oct 15, 2009, at 1:06 PM, Fayanna wrote: Hi there, I run the following code in R and got the warning like that, how can I change the memory.size? Or anything else? Thanks a lot! You haven't told us what type of machine you're on, or how much ram you have (it might very well be that you don't have enough ram on your system to load the data you're trying to load, no?) Anyway, still .. I'm guessing that: 1. You're on windows; and 2. You're stuck in 32bit land? Look through these: http://www.nabble.com/forum/Search.jtp?forum=13820local=yquery=windows+memory Hope that helps, -steve Faye temp-apply(Idd4.perms$permstats[-stratum1,], + 2,sort) Error: cannot allocate vector of size 47.5 Mb In addition: Warning messages: 1: In apply(Idd4.perms$permstats[-stratum1, ], 2, sort) : Reached total allocation of 1023Mb: see help(memory.size) 2: In apply(Idd4.perms$permstats[-stratum1, ], 2, sort) : Reached total allocation of 1023Mb: see help(memory.size) 3: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) 4: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) 5: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) 6: In unlist(ans, recursive = FALSE) : Reached total allocation of 1023Mb: see help(memory.size) -- View this message in context: http://www.nabble.com/Warning-messages%3A---Reached-total-allocation-of-1023Mb%3A-see-help%28memory.size%29-tp25912413p25912413.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. -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ 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] SPSS long variable names
Robert you are right. I updated the foreign package and I can read long names now I have checked the changelog and I found that long names reading were introduced after 0.8.29 while I were using 0.8.26-1. So I am really sorry guys for this mess. R can read long names. Caveman On Thu, Oct 15, 2009 at 9:42 PM, Orvalho Augusto orvaq...@gmail.com wrote: Impressive! PSPP produces the sav fine. The sav file produced by the PSPP is seen by SPSS (16) with the long names. I attach my sav produced by the PSPP. And I start to suspect my foreign package version: I am using 0.8.26-1 from the r-cran-foreign a Ubuntu 8.10 package. Can you tell me your version? I am updating mine. Thanks guys. Caveman On Thu, Oct 15, 2009 at 9:02 PM, Robert Baer rb...@atsu.edu wrote: The problem is the limit of 8 characters long on variable names.[in read.spss??] I just created a file in SPSS 17 and saved it in standard format (.sav) The file had four unique variable NAMES which were much longer than 8 characters (although not 64). I entered two rows of data and saved the file again. The variable view in SPSS looked like the following for the 4 variables I created. (unique in the first postition after the first 9) a12345678901234567890987654321098765432011 Numeric 8 2 a1234567890 None None 14 Right Scale a1234567899123456789098765432109876543201 Date 9 0 b1234567890 None None 14 Right Scale a1234567898123456789098765432109876543201 String 8 0 c1234567890 None None 14 Left Nominal a1234567897123456789098765432109876543201 Numeric 8 2 d1234567890 None None 14 Right Scale I now started R and used read.spss() from the foreign package using the following code The data frame I read in seemed to reflect the original file with respect to column names: library(foreign) c=read.spss(file.choose(),to.data.frame=TRUE) c a12345678901234567890987654321098765432011 a1234567899123456789098765432109876543201 a1234567898123456789098765432109876543201 1 33.3 13452825600 a cat 2 22.2 1346328 dog a1234567897123456789098765432109876543201 1 32165 2 321654987 It appears these long variable names read in just fine. Thus, I would ask caveman whether the problem is really an R problem at all, or is it a problem with PSPP writing (in which case this would be the wrong list to be discussing it on)? R __ 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 of means with glm model
Hi all, I have a data set that I am analyzing and I am trying to do a multiple comparison of means under a glm model. The factors are 2 light treatments and 3 temperature treatments in a complete block design analyzed using a glm. My question is how do I do a multiple comparison of means using the multcomp() package. I have used the following code to look at each treatment separately. germ.glht-glht(germ.glm,linfct=mcp(Light=Tukey)) but would like to add both temp and light. Is this possible, or is better to simply set up contrasts and adjust? Any help would be appreciated. Wade __ 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] reference on fisher.test()
Can somebody point me a book on Fisher's exact test? I looked a few webpages. But the descriptions on the webpages are not very complete. Is there a book on that covers all the aspect of Fisher's exact test that is implemented in R? __ 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] reference on fisher.test()
On Thu, Oct 15, 2009 at 4:56 PM, Peng Yu pengyu...@gmail.com wrote: Can somebody point me a book on Fisher's exact test? I looked a few webpages. But the descriptions on the webpages are not very complete. Is there a book on that covers all the aspect of Fisher's exact test that is implemented in R? Section 15.2 of my book (Statistical Analysis and Data Display, with Burt Holland and published by Springer) shows a detailed example. Rich __ 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] Trying get away from the for loop
Argh... I just realized the inefficiency of one of my loops so I am trying to get rid of it. I have two data frames: names(SubdivisionHouses) BuildYear, SqrFootage, Exterior names(BuildingCodes) Year, Codes I am trying to add on the the Codes column to according to the BuildYear Currently I am doing the following SubdivisionHouseMod-NULL for(hh in 1:unique(BuildingCodes$Year)) { SubdivisionHouses_tmp-subset(SubdivisionHouses, SubdivisionHouses$BuildYear == BuildingCodes$Year) BuildingCodes_tmp-subset(BuildingCodes, BuildingCodes$BuildYear == BuildingCodes[hh, ]$BuildYear) SubdivisionHouseMod_tmp-cbind(SubdivisionHouses_tmp, BuildingCodes_tmp$Codes) SubdivisionHouseMod-rbind(SubdivisionHouseMod, SubdivisionHouseMod_tmp) } Doing this seems to work, but it also seems to be really inefficient. Are there any suggestions of ways to cut this down and speed things up? Thanks again. __ 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] Trying get away from the for loop
You do not offer a workable example, but it appears you might be doing a merge operation. ?merge merge(SubdivisionHouses, BuildingCodes, by.x=BuildYear, by.y=Year) -- David On Oct 15, 2009, at 5:27 PM, Jason Rupert wrote: Argh... I just realized the inefficiency of one of my loops so I am trying to get rid of it. I have two data frames: names(SubdivisionHouses) BuildYear, SqrFootage, Exterior names(BuildingCodes) Year, Codes I am trying to add on the the Codes column to according to the BuildYear Currently I am doing the following SubdivisionHouseMod-NULL for(hh in 1:unique(BuildingCodes$Year)) { SubdivisionHouses_tmp-subset(SubdivisionHouses, SubdivisionHouses$BuildYear == BuildingCodes$Year) BuildingCodes_tmp-subset(BuildingCodes, BuildingCodes $BuildYear == BuildingCodes[hh, ]$BuildYear) SubdivisionHouseMod_tmp-cbind(SubdivisionHouses_tmp, BuildingCodes_tmp$Codes) SubdivisionHouseMod-rbind(SubdivisionHouseMod, SubdivisionHouseMod_tmp) } Doing this seems to work, but it also seems to be really inefficient. Are there any suggestions of ways to cut this down and speed things up? Thanks again. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] reference on fisher.test()
On Thu, Oct 15, 2009 at 4:19 PM, RICHARD M. HEIBERGER r...@temple.edu wrote: On Thu, Oct 15, 2009 at 4:56 PM, Peng Yu pengyu...@gmail.com wrote: Can somebody point me a book on Fisher's exact test? I looked a few webpages. But the descriptions on the webpages are not very complete. Is there a book on that covers all the aspect of Fisher's exact test that is implemented in R? Section 15.2 of my book (Statistical Analysis and Data Display, with Burt Holland and published by Springer) shows a detailed example. It doesn't mention odd ratio. __ 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] tapply() and using factor() on a factor
Dear List, Shouldn't result1 and result2 be equal in the following case? Note that log$RequestID is a factor. That is, is.factor(log$RequestID) yields TRUE. result1 - tapply(log$Flag,factor(log$RequestID),sum) result2 - tapply(log$Flag,log$RequestID,sum) Yet, when I summarize the output, I get the following: summary(result1) Min.1st Qu. Median Mean 3rd Qu.Max. 11.00 11.00 11.00 26.06 11.00 101.00 summary(result2) Min. 1st Qu. Median Mean 3rd Qu.Max.NA's 11.00 11.00 11.0026.06 11.00 101.00 978.00 Why does result2 have 978 NA's? Any help on this would be appreciated. Alex [[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] information
Hi!!, i'm Leonardo Olmedo, i'm student of master in Applied Mathematics in UAM and profesor in UNAM from Mexico. My thesis is a Proposal to test a central composite null hypothesis and alternative hypotheses bilateral in normal distribution. I did a program in R for obtain the significance level from test. I have a doubt: How can i do let my program be part of R and/or how i should have to write for this? 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] Solving an equation in R (and using a loop)
Hi So, I have a dataset and I'm trying to solve for a parameter in an equation using the dataset. Before applying more sophisticated statistical techniques, I want to tell R to solve it out for each observation. I know I have to use a loop for it (and I have done that before, but am a bit rusty), but before I do that, I'm trying to get R to solve it for just one observation, to make sure that I have that part right before applying to the rest. However, when I do it, I get 0 for an answer, which is a valid answer, but a trivial one. What am I doing wrong? (tips for the loop would also be appreciated, but this is my main concern right now.) Here's my code: f-function(r){1-exp(-r*b)-(1/2)*(1-exp(-r*x1)+1-exp(-r*x2))} uniroot(f,c(0,1))$root r is the unknown. I've plugged in a couple numbers from my data for b, x1, and x2 such as: b=5500 x1=0.01 x2=1 and b=198000 x1=10 x2=50 and gotten 0 both times. Thanks in advance for your help. -- View this message in context: http://www.nabble.com/Solving-an-equation-in-R-%28and-using-a-loop%29-tp25916187p25916187.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] Solving an equation in R (and using a loop)
On Oct 15, 2009, at 5:18 PM, leohearn wrote: So, I have a dataset and I'm trying to solve for a parameter in an equation using the dataset. Before applying more sophisticated statistical techniques, I want to tell R to solve it out for each observation. I know I have to use a loop for it (and I have done that before, but am a bit rusty), but before I do that, I'm trying to get R to solve it for just one observation, to make sure that I have that part right before applying to the rest. However, when I do it, I get 0 for an answer, which is a valid answer, but a trivial one. What am I doing wrong? (tips for the loop would also be appreciated, but this is my main concern right now.) Here's my code: f-function(r){1-exp(-r*b)-(1/2)*(1-exp(-r*x1)+1-exp(-r*x2))} What is this function supposed to represent? uniroot(f,c(0,1))$root r is the unknown. I've plugged in a couple numbers from my data for b, x1, and x2 such as: b=5500 x1=0.01 x2=1 and b=198000 x1=10 x2=50 and gotten 0 both times. Apparently you do understand that at zero that function would evaluate to 1-1- (1/2)*(1-1+1-1) for any value of the parameters. If you plot that function over the domain specified, you should see why there are no other solutions. Even with the first set of parameters f(1) is [1] 2.269996e-05 # which is close but not equal to zero Sometimes the trivial answer is the _only_ answer. Thanks in advance for your help. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Solving an equation in R (and using a loop)
I tried : test - 0:1 test2 - f(0:1) plot(test,test2) plot(test,log(test2)) and test - seq(0,1,by=0.1) test2 - sapply(test,f) plot(test,log(test2)) plot(test,test2) with the values you gave. And according to this result, you did nothing wrong. Zero is the only root of the function, as it is a monotone asymptotic to 0 for x0, and not defined for negative x. Are you sure you're looking for the root of that function? Cheers Joris On Thu, Oct 15, 2009 at 11:18 PM, leohearn leohe...@dal.ca wrote: Hi So, I have a dataset and I'm trying to solve for a parameter in an equation using the dataset. Before applying more sophisticated statistical techniques, I want to tell R to solve it out for each observation. I know I have to use a loop for it (and I have done that before, but am a bit rusty), but before I do that, I'm trying to get R to solve it for just one observation, to make sure that I have that part right before applying to the rest. However, when I do it, I get 0 for an answer, which is a valid answer, but a trivial one. What am I doing wrong? (tips for the loop would also be appreciated, but this is my main concern right now.) Here's my code: f-function(r){1-exp(-r*b)-(1/2)*(1-exp(-r*x1)+1-exp(-r*x2))} uniroot(f,c(0,1))$root r is the unknown. I've plugged in a couple numbers from my data for b, x1, and x2 such as: b=5500 x1=0.01 x2=1 and b=198000 x1=10 x2=50 and gotten 0 both times. Thanks in advance for your help. -- View this message in context: http://www.nabble.com/Solving-an-equation-in-R-%28and-using-a-loop%29-tp25916187p25916187.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.
Re: [R] Trying get away from the for loop
Thank you again for the suggestions to use merge: merge(SubdivisionHouses, BuildingCodes, by.x=BuildYear, by.y=Year) It appears to work perfectly for the example shown below: BuildYear-c(1980, 1985, 1975, 1990, 1980) SqrFootage-c(1500, 1650, 1500, 2000, 1450) Exterior-c(Brick, Stone, Siding, Brick, Siding) SubdivisionHouses-data.frame(BuildYear, SqrFootage, Exterior) Year-c(1980, 1985, 1975, 1990, 1977, 1986) Codes-c(G1, G5, G6, B5, B6, B7) BuildingCodes-data.frame(Year, Codes) SubdivisionHouseMod-NULL for(hh in 1:unique(BuildingCodes$Year)) { SubdivisionHouses_tmp-subset(SubdivisionHouses, SubdivisionHouses$BuildYear == BuildingCodes[hh, ]$Year) if(length(SubdivisionHouses_tmp$BuildYear) 0) { BuildingCodes_tmp-subset(BuildingCodes, BuildingCodes$Year == BuildingCodes[hh, ]$Year) SubdivisionHouseMod_tmp-cbind(SubdivisionHouses_tmp, BuildingCodes_tmp$Codes) SubdivisionHouseMod-rbind(SubdivisionHouseMod, SubdivisionHouseMod_tmp) } } Thank you again. --- On Thu, 10/15/09, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] Trying get away from the for loop To: Jason Rupert jasonkrup...@yahoo.com Cc: R-help@r-project.org Date: Thursday, October 15, 2009, 4:46 PM You do not offer a workable example, but it appears you might be doing a merge operation. ?merge merge(SubdivisionHouses, BuildingCodes, by.x=BuildYear, by.y=Year) --David On Oct 15, 2009, at 5:27 PM, Jason Rupert wrote: Argh... I just realized the inefficiency of one of my loops so I am trying to get rid of it. I have two data frames: names(SubdivisionHouses) BuildYear, SqrFootage, Exterior names(BuildingCodes) Year, Codes I am trying to add on the the Codes column to according to the BuildYear Currently I am doing the following SubdivisionHouseMod-NULL for(hh in 1:unique(BuildingCodes$Year)) { SubdivisionHouses_tmp-subset(SubdivisionHouses, SubdivisionHouses$BuildYear == BuildingCodes$Year) BuildingCodes_tmp-subset(BuildingCodes, BuildingCodes$BuildYear == BuildingCodes[hh, ]$BuildYear) SubdivisionHouseMod_tmp-cbind(SubdivisionHouses_tmp, BuildingCodes_tmp$Codes) SubdivisionHouseMod-rbind(SubdivisionHouseMod, SubdivisionHouseMod_tmp) } Doing this seems to work, but it also seems to be really inefficient. Are there any suggestions of ways to cut this down and speed things up? Thanks again. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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 install JGR manually?
Here's the problem: on Windows, the 'jgr.exe' tool starts up by checking for a connecting to the 'net in order to grab the support packages. Well, we have machines at work that are not and never will be connected to the Internet. I tried manually installing all the packages (JGR, Rjava, etc) but the jgr.exe still tries to find a connection. Is there any way around this? thanks Carl __ 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] Generating a stochastic matrix with a specified second dominant eigenvalue
I just tried the following shot in the dark: generate an N by N stochastic matrix, M. I used M = matrix(runif(9),nrow=3) M = M/apply(M,1,sum) e=eigen(M) e$values[2]= .7 (pick your favorite lambda, you may need to fiddle with the others to guarantee this is second largest.) Q = e$vectors Qi = solve(Q) B = Q %*% diag(e$values) %*% Qi eigen(B)$values [1] 1. 0.7000 -0.08518772 apply(B,1,sum) [1] 1 1 1 I haven't proven that this must work, but it seems to. Since you can verify that it worked afterwards, perhaps the proof is in the pudding. albyn On Thu, Oct 15, 2009 at 06:24:20PM -0400, Ravi Varadhan wrote: Hi, Given a positive integer N, and a real number \lambda such that 0 \lambda 1, I would like to generate an N by N stochastic matrix (a matrix with all the rows summing to 1), such that it has the second largest eigenvalue equal to \lambda (Note: the dominant eigenvalue of a stochastic matrix is 1). I don't care what the other eigenvalues are. The second eigenvalue is important in that it governs the rate at which the random process given by the stochastic matrix converges to its stationary distribution. Does anyone know of an algorithm to do this? Thanks for any help, Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan. html http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml [[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.
[R] How to right-align labels in dotchart
I have only just discovered the joys of the dotchart (since I am reading William Cleveland's -- Sean Carmody The Stubborn Mule http://www.stubbornmule.net http://twitter.com/seancarmody [[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] How to right-align labels in dotchart
Pressed send too soon (apologies). Meant to say I have only just discovered the joys of the dotchart (since I am reading William Cleveland's The Elements of Graphing Data). However, I cannot work out how to change the alignment of the text labels from left to right. Regards, Sean. On Fri, Oct 16, 2009 at 10:51 AM, Sean Carmody seancarm...@gmail.comwrote: I have only just discovered the joys of the dotchart (since I am reading William Cleveland's -- Sean Carmody The Stubborn Mule http://www.stubbornmule.net http://twitter.com/seancarmody -- Sean Carmody The Stubborn Mule http://www.stubbornmule.net http://twitter.com/seancarmody [[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] Data frame search and remove questions
Hello, I have a couple questions about removing rows from a data frame and creating a new data frame with the removed values. I provided an example data frame (d) below. Questions: 1) How can I search for -999.000 and remove the entire row from data frame d? (all -999 values will be in sd_diff) 2) Can I create a new data frame d.new that only contains the removed rows? 3) How can I remove the last two rows from a data frame. (I used append command to add two values to the end of the data) d lat.add lon.add PPT.add Z.add sd_dif 137.67 -95.48 1.000 368 1.017 238.82 -92.22 13.208 383 5.737 337.30 -95.50 6.096 130 4.377 437.08 -95.57 0.508 106 -999.000 538.73 -93.55 6.350 370 6.233 638.83 -94.88 0.254 5 8.607 738.33 -96.18 0.50843 8.665 838.85 -94.73 1.000 5 -999.000 938.71 -93.16 1.016 320 3.717 10 38.95 -95.67 1.000 5 8.553 d.new lat.add lon.add PPT.add Z.add sd_dif 137.08 -95.57 0.508 106 -999.000 238.85 -94.73 1.000 5 -999.000 Thanks for all the help, Doug -- - Douglas M. Hultstrand, MS Senior Hydrometeorologist Metstat, Inc. Windsor, Colorado voice: 970.686.1253 email: dmhul...@metstat.com web: http://www.metstat.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] Data frame search and remove questions
On Oct 15, 2009, at 1:17 PM, Douglas M. Hultstrand wrote: Hello, I have a couple questions about removing rows from a data frame and creating a new data frame with the removed values. I provided an example data frame (d) below. Questions: 1) How can I search for -999.000 and remove the entire row from data frame d? (all -999 values will be in sd_diff) 2) Can I create a new data frame d.new that only contains the removed rows? 3) How can I remove the last two rows from a data frame. (I used append command to add two values to the end of the data) d lat.add lon.add PPT.add Z.add sd_dif 137.67 -95.48 1.000 368 1.017 238.82 -92.22 13.208 383 5.737 337.30 -95.50 6.096 130 4.377 437.08 -95.57 0.508 106 -999.000 538.73 -93.55 6.350 370 6.233 638.83 -94.88 0.254 5 8.607 738.33 -96.18 0.50843 8.665 838.85 -94.73 1.000 5 -999.000 938.71 -93.16 1.016 320 3.717 10 38.95 -95.67 1.000 5 8.553 d.new lat.add lon.add PPT.add Z.add sd_dif 137.08 -95.57 0.508 106 -999.000 238.85 -94.73 1.000 5 -999.000 You asked about -999.000 which would be a character value, but you displayed what appears to be a numeric column since there were no quotes. That is the reason we ask for executable examples which yours is not. You could have resolved this ambiguity if you have some aversion to using dput(d) by at least offering the output of str(d). At any rate, if it is a numeric column this should work even if the -999's are not in sd_dif. d[apply(d , 1, function(x) -999 %in% x), ] lat.add lon.add PPT.add Z.add sd_dif 4 37.08 -95.57 0.508 106 -999 8 38.85 -94.73 1.000 5 -999 Or if they are for certain in sd_dif, then: d[d$sd_dif==-999, ] Thanks for all the help, Doug -- - Douglas M. Hultstrand, MS Senior Hydrometeorologist Metstat, Inc. Windsor, Colorado voice: 970.686.1253 email: dmhul...@metstat.com web: http://www.metstat.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. David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] Solving an equation in R (and using a loop)
Thank you both for your help. I'll ask my advisor for help on the issue tomorrow as perhaps I've made a specification error or I'm taking the wrong approach entirely. I'm a master's student in economics; the equation is a CARA utility function, and the r represents the corresponding individual's coefficient of risk aversion. Perhaps I just have a selection bias since I am choosing from observations that only have x1 and x2, when I have some observations that go all the way up to x20. (so the part of f which follows the negative sign would be (1/n)(sum(1-exp(-rx(i)). I am solving for r when that equation equals 0, so, yes, I'm looking for the root. I'll try with a few more observations that have more xs. cheers Laura leohearn wrote: Hi So, I have a dataset and I'm trying to solve for a parameter in an equation using the dataset. Before applying more sophisticated statistical techniques, I want to tell R to solve it out for each observation. I know I have to use a loop for it (and I have done that before, but am a bit rusty), but before I do that, I'm trying to get R to solve it for just one observation, to make sure that I have that part right before applying to the rest. However, when I do it, I get 0 for an answer, which is a valid answer, but a trivial one. What am I doing wrong? (tips for the loop would also be appreciated, but this is my main concern right now.) Here's my code: f-function(r){1-exp(-r*b)-(1/2)*(1-exp(-r*x1)+1-exp(-r*x2))} uniroot(f,c(0,1))$root r is the unknown. I've plugged in a couple numbers from my data for b, x1, and x2 such as: b=5500 x1=0.01 x2=1 and b=198000 x1=10 x2=50 and gotten 0 both times. Thanks in advance for your help. -- View this message in context: http://www.nabble.com/Solving-an-equation-in-R-%28and-using-a-loop%29-tp25916187p25917285.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] converting to data.frame
dear all I have a data set with three types (Tree, Sapling, Seedling). I have estimated the correlation values. now i need to bring all the correlation values in a table like the one i have shown in attached file with R codes.could you please give me idea on this problem thanking you MS Nepal _ Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. http://clk.atdmt.com/GBL/go/171222985/direct/01/read.table() colnames(c.df) [1] id codelonglat elevage_obs year [8] Est_age Ht_cm BD_mm CDA_cm CDB_cm growth type ### Correlation estimation cor(age_obs,Ht_cm) cor(age_obs[type=='SD'],Ht_cm[type=='SD']) #seedling cor(age_obs[type=='SPB'],Ht_cm[type=='SPB'])#sapling cor(age_obs[type=='T'],Ht_cm[type=='T'])#tree cor(age_obs,BD_mm) cor(age_obs[type=='SD'],BD_mm[type=='SD']) cor(age_obs[type=='SPB'],BD_mm[type=='SPB']) cor(age_obs[type=='T'],BD_mm[type=='T']) cor(age_obs,CDA_cm) cor(age_obs[type=='SD'],CDA_cm[type=='SD']) cor(age_obs[type=='SPB'],CDA_cm[type=='SPB']) cor(age_obs[type=='T'],CDA_cm[type=='T']) cor(age_obs,CDB_cm) cor(age_obs[type=='SD'],CDB_cm[type=='SD']) cor(age_obs[type=='SPB'],CDB_cm[type=='SPB']) cor(age_obs[type=='T'],CDB_cm[type=='T']) cor(Ht_cm,BD_mm) cor(Ht_cm[type=='SD'],BD_mm[type=='SD']) cor(Ht_cm[type=='SPB'],BD_mm[type=='SPB']) cor(Ht_cm[type=='T'],BD_mm[type=='T']) cor(Ht_cm,CDA_cm) cor(Ht_cm[type=='SD'],CDA_cm[type=='SD']) cor(Ht_cm[type=='SPB'],CDA_cm[type=='SPB']) cor(Ht_cm[type=='T'],CDA_cm[type=='T']) cor(Ht_cm,CDB_cm) cor(Ht_cm[type=='SD'],CDB_cm[type=='SD']) cor(Ht_cm[type=='SPB'],CDB_cm[type=='SPB']) cor(Ht_cm[type=='T'],CDB_cm[type=='T']) cor(BD_mm,CDA_cm) cor(BD_mm[type=='SD'],CDA_cm[type=='SD']) cor(BD_mm[type=='SPB'],CDA_cm[type=='SPB']) cor(BD_mm[type=='T'],CDA_cm[type=='T']) cor(BD_mm,CDB_cm) cor(BD_mm[type=='SD'],CDB_cm[type=='SD']) cor(BD_mm[type=='SPB'],CDB_cm[type=='SPB']) cor(BD_mm[type=='T'],CDB_cm[type=='T']) cor(CDA_cm,CDB_cm) cor(CDA_cm[type=='SD'],CDB_cm[type=='SD']) cor(CDA_cm[type=='SPB'],CDB_cm[type=='SPB']) cor(CDA_cm[type=='T'],CDB_cm[type=='T']) cor(age_obs,Est_age,use=pairwise.complete.obs) cor(age_obs[type=='SD'],Est_age[type=='SD'],use=pairwise.complete.obs) cor(age_obs[type=='SPB'],Est_age[type=='SPB'],use=pairwise.complete.obs) cor(age_obs[type=='T'],Est_age[type=='T'],use=pairwise.complete.obs) ### table looks like below one parameters combinedseedlingsapling tree age_obs Vs Ht_cm age_obs Vs BD_mm age_obs Vs CDA_cm age_obs Vs CDB_cm Ht_cm Vs BD_mm Ht_cm Vs CDA_cm Ht_cm Vs CDB_cm BD_mm Vs CDA_cm BD_mm Vs CDB_cm CDA_cm Vs CDB_cm age_obs Vs est_age __ 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] converting to data.frame
Make the example reproducible. Us dput() or make up data that illustrates the problem. The nice folks on this list volunteer their time, so try and make the the help easier to give. And please read the posting guide if you haven't. commented, minimal, self-contained, reproducible code... like it says at the end of ever email. I am not perfect and have done this more than my fair share, but I am getting better. regards, On Thu, Oct 15, 2009 at 9:07 PM, ms.com logi...@hotmail.com wrote: dear all I have a data set with three types (Tree, Sapling, Seedling). I have estimated the correlation values. now i need to bring all the correlation values in a table like the one i have shown in attached file with R codes.could you please give me idea on this problem thanking you MS Nepal _ Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. http://clk.atdmt.com/GBL/go/171222985/direct/01/ __ 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. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ 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] converting to data.frame
You probably could have saved some time by installing Hmisc and using rcorr: ---something like: require(Hmisc) typecors - tapply(c.df[ , c(age_obs, Ht_cm, BD_mm, CDA_cm, CDB_cm) ], c.df$type, rcorr ) The upper or lower triangle of those results could have populated most of your table and you could cbind the combined result of: combcors - rcorr(c.df[ , c(age_obs, Ht_cm, BD_mm, CDA_cm, CDB_cm) ]) ... and add the age_obs Vs est_age row. Tables are actually matrices and use the same sort of indexing. Cbind and rbind augment columnwise and rowwise. -- David On Oct 15, 2009, at 10:07 PM, ms.com wrote: dear all I have a data set with three types (Tree, Sapling, Seedling). I have estimated the correlation values. now i need to bring all the correlation values in a table like the one i have shown in attached file with R codes.could you please give me idea on this problem thanking you David Winsemius, MD Heritage Laboratories West Hartford, CT __ 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] tapply() and using factor() on a factor
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Peterhansl Sent: Thursday, October 15, 2009 2:50 PM To: r-help@r-project.org Subject: [R] tapply() and using factor() on a factor Dear List, Shouldn't result1 and result2 be equal in the following case? Note that log$RequestID is a factor. That is, is.factor(log$RequestID) yields TRUE. result1 - tapply(log$Flag,factor(log$RequestID),sum) result2 - tapply(log$Flag,log$RequestID,sum) Showing us the output of dput(log) (or str(log) and summary(log)) would let people discover the problem more readily. Since you didn't I'll guess what the dataset may contain. If log$RequestID is a factor with lots of unused levels tapply will output an NA for each unused level. factor(log$RequestID) will create a new set of levels, only those actually used, so tapply will not be forced to fill those spots with NA's. E.g., log-data.frame(Flag=1:2, RequestID=factor(letters[1:2], levels=letters[1:10])) tapply(log$Flag, log$RequestID, sum) a b c d e f g h i j 1 2 NA NA NA NA NA NA NA NA tapply(log$Flag, factor(log$RequestID), sum) a b 1 2 I suppose tapply(X,INDEX,FUN) could call FUN(X[0]) to see how to fill the cells with no data behind them, but it doesn't. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Yet, when I summarize the output, I get the following: summary(result1) Min.1st Qu. Median Mean 3rd Qu.Max. 11.00 11.00 11.00 26.06 11.00 101.00 summary(result2) Min. 1st Qu. Median Mean 3rd Qu.Max.NA's 11.00 11.00 11.0026.06 11.00 101.00 978.00 Why does result2 have 978 NA's? Any help on this would be appreciated. Alex [[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.