[R] question
hello can you explain to me about package shapes in R software? especially about order procGPA? [[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] question about heatmap.2, controlling the visual heights of two dendrograms
Hi, I have a question for gplots function heatmap.2. In this function, is there any way to control/know the heights of two dendrograms, such as how many pixels or how many percentage of the whole image the dendrogram have? I need to know the coordinates of northwest corner of real heatmap in the whole image including two dendrograms. Thanks for your help! Tim [[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] Control y axis
Hi, The bracket after lty=1 should be replaced with comma (,). x<-1:15 y<--8:6 plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,lty=1,xlim=range(1:14),ylim=range(-8:8),las=1) A.K. - Original Message - From: stefaniewind To: r-help@r-project.org Cc: Sent: Friday, July 20, 2012 3:29 PM Subject: [R] Control y axis I can't get the y axis to extend the full range that I need, which is -8 to 8 Here's my code. I tried using ylim, but it's still truncating at the extremes in my data. plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,lty=1) xlim=range(1:14),ylim=range(-8:8), las=1) Any suggestions? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Control-y-axis-tp4637266.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] library XML in R version 2.15.1
HI, I have XML library installed in R2.15 and is working fine. I used it only a few times, it was working. I am using Ubuntu 12.04. A.K. - Original Message - From: Santosh To: r-help Cc: Sent: Friday, July 20, 2012 11:03 PM Subject: [R] library XML in R version 2.15.1 Hello Rxperts.. I have a peculiar situation.. XML library is not available with R2.15.1 whereas I was able to install it with R version 2.13.1. Would highly appreciate your suggestions. I am now trying to see if XML works with previous versions of R. Thanks, Santosh [[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] GOstats: get genes for corresponding enriched GO term
Hello, I guess this should be posted in the bioconductor mailing list to get better response. I never used Gostats before, but I think BINGO and DAVID are very good in giving these information. I would choose BINGO plugin in cytoscape installed. But, you may have specific reasons to use Gostats. A.K. - Original Message - From: Lan Sky To: r-help@r-project.org Cc: Sent: Friday, July 20, 2012 8:29 PM Subject: [R] GOstats: get genes for corresponding enriched GO term Hi, I used GOstats to perform enrichment test on a set of genes (20). There are 7 GO terms with pvalue less than cuttoff and therefore shown in the result table. How can I get the information that which gene in the input gene set belong to which GO term of these enriched GO terms? Thanks for any comments. best, Tim [[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] Control y axis
Hi, You can try this: x<-1:15 y<--8:6 plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,axes=FALSE) axis(1,at=c(0,2,4,6,8,10,12,14,16)) axis(2,at=c(-8,-6,-4,-2,0,2,4,6,8)) A.K. From: Stefanie Wind To: arun Sent: Friday, July 20, 2012 11:42 PM Subject: Re: [R] Control y axis Thanks! Do you know how I could get the values -8:8 to print on the y axis? On Fri, Jul 20, 2012 at 9:06 PM, arun wrote: Hi, > >The bracket after lty=1 should be replaced with comma (,). > x<-1:15 > y<--8:6 > plot(x, y, type ="o", xlab="Panelist", ylab="T >value",lwd=1.5,lty=1,xlim=range(1:14),ylim=range(-8:8),las=1) > >A.K. > > > > >- Original Message - >From: stefaniewind >To: r-help@r-project.org >Cc: >Sent: Friday, July 20, 2012 3:29 PM >Subject: [R] Control y axis > >I can't get the y axis to extend the full range that I need, which is -8 to 8 > >Here's my code. I tried using ylim, but it's still truncating at the >extremes in my data. > >plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,lty=1) >xlim=range(1:14),ylim=range(-8:8), las=1) > > >Any suggestions? > >Thanks! > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/Control-y-axis-tp4637266.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] fitting Ornstein-Uhlenbeck process by MAXIMUM LIKELYHOOD
Hello, When computing Sxx, Syy and you are mistaking the square of the sum for the sum of squares. The same goes for the crossed term Sxy, it's the sum of the products, not the product of the sums Sx and Sy. Hope this helps, Rui Barradas Em 20-07-2012 23:04, cesare orsini escreveu: Dear friends i am trying to fit an Ornstein-Uhlenbeck process by MAXIMUM LIKELYHOOD method. i found these formulas on http://www.sitmo.com/article/calibrating-the-ornstein-uhlenbeck-model/ this is the mean-reverting process http://r.789695.n4.nabble.com/file/n4637271/process.txt process.txt and this is the script that i am using... ouFit.ML=function(spread) { n=length(spread) delta=n/n Sx=sum(spread[1:n-1]) Sy=sum(spread[2:n]) Sxx=(Sx)^2 Syy=(Sy)^2 Sxy=Sx*Sy mu = (Sy*Sxx - Sx*Sxy) / ( n*(Sxx - Sxy) - (Sx^2 - Sx*Sy) ) lambda = -log( (Sxy - mu*Sx - mu*Sy + n*mu^2) / (Sxx -2*mu*Sx + n*mu^2) )/delta a = exp(-lambda*delta) sigmah2 = (Syy - 2*a*Sxy + a^2*Sxx - 2*mu*(1-a)*(Sy - a*Sx) + n*mu^2*(1-a)^2)/n; sigma = sqrt((sigmah2)*2*lambda/(1-a^2)) theta=list(lambda=lambda, mu=mu,sigma=sigma,sigmah2=sigmah2) return(theta) } where is my error? is there some other script to obtain a good result by the same method? thank you!!! :-) -- View this message in context: http://r.789695.n4.nabble.com/fitting-Ornstein-Uhlenbeck-process-by-MAXIMUM-LIKELYHOOD-tp4637271.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] qplot/ggplot
Hello, You can try either one of these methods:: #Simple line plot dat1<-read.table(text=" Gene1 10 14 12 23 11 11 33 1 Gene2 4 2 1 1 3 4 1 2 Gene3 2 5 7 5 6 89 7 3 Gene4 1 9 8 3 90 8 8 5 ",sep="",header=FALSE,stringsAsFactors=FALSE) dat2<-as.data.frame(t(dat1[,-1])) colnames(dat2)<-paste("Gene",1:4,sep="") rownames(dat2)<-1:nrow(dat2) str(dat2) dat3<-data.frame(dat2,index=1:8) plot(0,type="n",main="Genes line plot",ylab="Expression",xlim=c(0,10),ylim=c(0,100)) lines(dat3$index,dat3$Gene1,col="orange") lines(dat3$index,dat3$Gene2,col="green") lines(dat3$index,dat3$Gene3,col="blue") lines(dat3$index,dat3$Gene4,col="red") points(dat3$index,dat3$Gene1,col="orange",pch=1) points(dat3$index,dat3$Gene2,col="green",pch=2) points(dat3$index,dat3$Gene3,col="blue",pch=3) points(dat3$index,dat3$Gene4,col="red",pch=4) legend("topright",c("Gene1","Gene2","Gene3","Gene4"),col=c("orange","green","blue","red"),lty=1,pch=c(1:4)) #ggplot library(ggplot2) dat3mlt<-melt(dat3,id.vars="index") #1 ggplot(dat3mlt, aes(x=index, y=value, colour=variable))+stat_smooth(method="lm")+geom_point() #2 ggplot(dat3mlt, aes(x=index, y=value, colour=variable))+stat_smooth(method="lm",formula=y~ns(x,3))+geom_point() #3 ggplot(dat3mlt, aes(x=index, y=value, colour=variable))+stat_smooth(fill="green",size=2)+geom_point() Hope this helps you. A.K. - Original Message - From: Anamika K To: r-help@r-project.org Cc: Sent: Friday, July 20, 2012 6:57 AM Subject: [R] qplot/ggplot Hello, I have a file like this (just a snapshot) where I have numerical values for various genes, I want a line plot with shading (may be using smooth ?) using qplot or ggplot : Gene1 10 14 12 23 11 11 33 1 ..(multiple columns) Gene2 4 2 1 1 3 4 1 2 . Gene3 2 5 7 5 6 89 7 3 .. Gene4 1 9 8 3 90 8 8 . Please help. Ana __ 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] library XML in R version 2.15.1
Hi, So, you got the same error message for R 2.14.1 and R 2.15? Or is it only for R 2.15? It is always good to install the current version. Try this: install.packages("XML",dependencies=TRUE) #Warning message suggests dependencies. A.K. - Original Message - From: Santosh To: R help Cc: Sent: Friday, July 20, 2012 11:24 PM Subject: Re: [R] library XML in R version 2.15.1 Thanks for your response. I tried R.2.15 also and just tried R.14.1 in 32-bit Windows Vista. Below is the error message I received. > install.packages("XML") Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘XML’ is not available (for R version 2.14.1) > Santosh On Fri, Jul 20, 2012 at 8:16 PM, arun wrote: > HI, > > I have XML library installed in R2.15 and is working fine. I used it only > a few times, it was working. I am using Ubuntu 12.04. > > A.K. > > > > - Original Message - > From: Santosh > To: r-help > Cc: > Sent: Friday, July 20, 2012 11:03 PM > Subject: [R] library XML in R version 2.15.1 > > Hello Rxperts.. > > I have a peculiar situation.. XML library is not available with R2.15.1 > whereas I was able to install it with R version 2.13.1. Would highly > appreciate your suggestions. I am now trying to see if XML works with > previous versions of R. > > Thanks, > Santosh > > [[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-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] question
On Saturday, July 21, 2012, Mehrab Nodehi wrote: > hello > can you explain to me about package shapes in R software? > especially about order procGPA? Not unless you read the posting guide and formulate a more specific question. Sarah -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[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] information
On 07/18/2012 09:11 PM, Karan Anand wrote: hi, i am new to using R, so if u can help me in merging my csv file having different sheets .if u can help me with the commands for it. Hi karan, I didn't see an answer for your question. If you are reading in several CSV files with the same number of columns, you can use "rbind": sheet1<-read.csv("df1.csv") sheet2<-read.csv("df2.csv") sheet1 V1 V2 1 23 14 2 31 27 3 19 22 sheet2 V1 V2 1 17 41 2 30 23 3 11 32 bothsheets<-rbind((sheet1,sheet2) bothsheets V1 V2 1 23 14 2 31 27 3 19 22 1 17 41 2 30 23 3 11 32 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.
[R] alternative to rbind for data.table
Hi I want to add a row to a "data.table" in each round of a for loop. "rbind" seems to be a inefficient way to implement this. How would you do this? The "slow" solution: library(data.table) Rprof("test.out") dt <- data.table() for (i in (1:1)) { # algorithm that generates a list with different values, # but same key-names, each round, for example l <- list(A=1,B=2,C=3,E=4,F=5) dt <- rbind(dt,l) # very slow :( } Rprof(NULL) summaryRprof("test.out") thx Christof __ 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] 'symbols' not plotting correct circle radii
On 07/20/2012 12:33 AM, Stuart Leask wrote: You're right - easily tested by just re-sizing the graphics box - sort of counter-intuitive until I remember the clue is in the name - this generates a CIRCLE, come what may... Stuart From: Sarah Goslee [mailto:sarah.gos...@gmail.com] Sent: 19 July 2012 11:18 To: Stuart Leask Cc: r-help@r-project.org Subject: Re: [R] 'symbols' not plotting correct circle radii On Thursday, July 19, 2012, Stuart Leask wrote: (Oh, and yes I've tried setting 'inches=F', but I then get a circle correct on X axis, but too large on the Y axis.) We're back to "read the help." ?symbols explictly states that if inches=FALSE and the axis scales are different, then the x axis coordinates will be used. And if your axes are different, why would you expect a *circle* to fit both simultaneously? Perhaps instead you need plot.ellipse from the plotrix package. Hi all, You might want to use draw.circle from the plotrix package, as it tries to compensate for different axis scales. 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] Speeding up a loop
next for loop question. I need a loop that removes a row from a matrix if it is worse in positions 1,2,3,4 than another row in the matrix. right now my matrix is 503028x26. Rule to define worse position1 is smaller, position2 is smaller, position3 is higher, and position4 is smaller Example: row1: 1, 10, 3, 3 row2: 3, 7, 5, 2 row2 is not worse than row1 since it is "better" in position 1, eventhough it is worse in all other positions. row3: 2,5,7,1 row3 however is worse than row2 and should be removed from the matrix. Any ideas? Should I break this into pieces or do it all at once? Is there something faster than a loop? My current loops takes well over 24 hours to run. m<-matrix(0,1,24) for(i in 1:n) { a<-matrix(x[i,1:4],1,4) j=1 nn<-nrow(m) counter<-0 while(j<=nn) { if(a[1]>m[j,1] && a[2]>m[j,2] && a[3]>m[j,4] && a[4]min(m[,1]) || a[3]>min(m[,3]) || a[4]>min(m[,4]) || a[5]http://r.789695.n4.nabble.com/Speeding-up-a-loop-tp4637201p4637305.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] EM for missing data
Hi list, I am wondering if there is a way to use EM algorithm to handle missing data and get a completed data set in R? I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated value for the missing data, and then the completed dataset can be saved and used for further analysis. But I have not found a way to get the a completed data set like this in R or SAS. With Amelia or MICE, the missing data set were imputed a couple of times, and the new imputed datasets were not combined. I understand that the parameter estimation can still be done in the way of combination of estimates from each imputed data set, but it would be more convenient to have a combined dataset to do some analysis, for example, ANOVA with IVs having more than two categories. In this case, the only way to get the main effect of the whole IV is to estimate parameters in a single data set(as far as I know). If the separated imputed data sets were used, then the main effect showed in the result were for each category of the IV, respectively. I figured sometimes the readers and reviewers would like to see how bi! g the effect for the whole IV instead of the effect of each category of that IV. This is one of the reasons I can not fully move to R from SPSS. So any suggestions? Thank you very much. ya [[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] combined EM dataset for missing data?
Hi list, I am wondering if there is a way to use EM algorithm to handle missing data and get a completed data set in R? I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated value for the missing data, and then the completed dataset can be saved and used for further analysis. But I have not found a way to get the a completed data set like this in R or SAS. With Amelia or MICE, the missing data set were imputed a couple of times, and the new imputed datasets were not combined. I understand that the parameter estimation can still be done in the way of combination of estimates from each imputed data set, but it would be more convenient to have a combined dataset to do some analysis, for example, ANOVA with IVs having more than two categories. In this case, the only way to get the main effect of the whole IV is to estimate parameters in a single data set(as far as I know). If the separated imputed data sets were used, then the main effect showed in the result were for each category of the IV, respectively. I figured sometimes the readers and reviewers would like to see how bi! g the effect for the whole IV instead of the effect of each category of that IV. This is one of the reasons I can not fully move to R from SPSS. So any suggestions? Thank you very much. ya [[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] changing cex pointwise in lattice
I'm sorry I misunderstood your original request. You're right, use subscripts for panel-specific argument values. Peter Ehlers On 2012-07-20 19:35, "José M. Blanco Moreno" wrote: Sorry about that, when I asked before I meant that I had tried your proposed syntax. That has a problem, and it is that it uses the same set of values for the character expansion *for both groups*, and it is not what I wanted to do. If you plot the data (now a reduced set! sorry!) you'll see that both plots are exactly the same: I have data on the same positions, but the values that I want to represent with cex are different for each group. The intention is to take advantage of the fact that (I think that) lattice will use the same scaling on both plots. I think I have found it... # This is just to make sure that a group has a value of 1 and the other of 2 dd$z <- (1:50)%%2 + 1 xyplot(y~x|group, panel=function(x,y,subscripts){panel.xyplot(x,y, cex=dd$z[subscripts])}, data=dd) Cheers, José M. Blanco El 20/07/2012 21:34, Peter Ehlers escribió: Sorry, I had meant to include the following line: Try: xyplot(y~x|group,cex=dd$z,data=dd) Peter Ehlers structure(list(y = c(3L, 3L, 3L, 3L, 9L, 9L, 9L, 9L, 38L, 38L, 38L, 38L, 44L, 44L, 44L, 44L, 38L, 38L, 38L, 38L, 44L, 44L, 44L, 44L, 38L, 38L, 38L, 38L, 44L, 44L, 44L, 44L, 54L, 54L, 54L, 54L, 60L, 60L, 60L, 60L, 54L, 54L, 54L, 54L, 60L, 60L, 60L, 60L, 54L, 54L), x = c(3.25, 3.25, 9.75, 9.75, 3.25, 3.25, 9.75, 9.75, 16.25, 16.25, 22.75, 22.75, 16.25, 16.25, 22.75, 22.75, 29.25, 29.25, 35.75, 35.75, 29.25, 29.25, 35.75, 35.75, 42.25, 42.25, 48.75, 48.75, 42.25, 42.25, 48.75, 48.75, 3.25, 3.25, 9.75, 9.75, 3.25, 3.25, 9.75, 9.75, 16.25, 16.25, 22.75, 22.75, 16.25, 16.25, 22.75, 22.75, 29.25, 29.25), group = structure(c(2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("B", "A"), class = "factor"), z = c(2, 0, 8, 3, 3, 4, 5, 4, 14, 11, 4, 2, 37, 7, 6, 5, 4, 3, 14, 5, 9, 3, 3, 1, 9, 4, 9, 7, 4, 2, 9, 1, 9, 2, 9, 1, 5, 2, 10, 1, 13, 5, 14, 4, 21, 6, 16, 3, 0, 1)), .Names = c("y", "x", "group", "z"), row.names = c(NA, 50L ), class = "data.frame") -- --- José M. Blanco-Moreno Dept. de Biologia Vegetal (Botànica) Facultat de Biologia Universitat de Barcelona Av. Diagonal 643 08028 Barcelona SPAIN --- phone: (+34) 934 039 863 fax: (+34) 934 112 842 --- The best argument against democracy is a five-minute conversation with the average voter. -Winston Churchill, statesman, military and author (1874-1965) Aquest correu electrònic i els annexos poden contenir informació confidencial o protegida legalment i està adreçat exclusivament a la persona o entitat destinatària. Si no sou el destinatari final o la persona encarregada de rebre’l, no esteu autoritzat a llegir-lo, retenir-lo, modificar-lo, distribuir-lo, copiar-lo ni a revelar-ne el contingut. Si heu rebut aquest correu electrònic per error, us preguem que n’informeu al remitent i que elimineu del sistema el missatge i el material annex que pugui contenir. Gràcies per la vostra col·laboració. Este correo electrónico y sus anexos pueden contener información confidencial o legalmente protegida y está exclusivamente dirigido a la persona o entidad destinataria. Si usted no es el destinatario final o la persona encargada de recibirlo, no está autorizado a leerlo, retenerlo, modificarlo, distribuirlo, copiarlo ni a revelar su contenido. Si ha recibido este mensaje electrónico por error, le rogamos que informe al remitente y elimine del sistema el mensaje y el material anexo que pueda contener. Gracias por su colaboración. This email message and any documents attached to it may contain confidential or legally protected material and are intended solely for the use of the individual or organization to whom they are addressed. We remind you that if you are not the intended recipient of this email message or the person responsible for processing it, then you are not authorized to read, save, modify, send, copy or disclose any of its contents. If you have received this email message by mistake, we kindly ask you to inform the sender of this and to eliminate both the message and any attachments it carries from your account. Thank you for your collaboration. __ 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] combined EM dataset for missing data?
Search yourself! 1. Google on "Impute missing data in R" 2. See the ?RSiteSearch function 3. Go to Rseek.org and enter in keywords. 4. Download and install the sos package and use its search functionality. R has multiple packages and functions with multiple approaches to missing data imputation. Choose what you need. -- Bert On Sat, Jul 21, 2012 at 4:58 AM, ya wrote: > > Hi list, > > I am wondering if there is a way to use EM algorithm to handle missing data > and get a completed data set in R? > > I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated > value for the missing data, and then the completed dataset can be saved and > used for further analysis. But I have not found a way to get the a completed > data set like this in R or SAS. With Amelia or MICE, the missing data set > were imputed a couple of times, and the new imputed datasets were not > combined. I understand that the parameter estimation can still be done in the > way of combination of estimates from each imputed data set, but it would be > more convenient to have a combined dataset to do some analysis, for example, > ANOVA with IVs having more than two categories. In this case, the only way to > get the main effect of the whole IV is to estimate parameters in a single > data set(as far as I know). If the separated imputed data sets were used, > then the main effect showed in the result were for each category of the IV, > respectively. I figured sometimes the readers and reviewers would like to see > how ! bi! > g the effect for the whole IV instead of the effect of each category of that > IV. > > This is one of the reasons I can not fully move to R from SPSS. So any > suggestions? > > Thank you very much. > > > > > ya > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] deactivate my account from your members
please don't send email to this email address: mehdi.p...@gmail.com lots of thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Speeding up a loop
Hello, Maybe it would have been better to start a new thread, if the question is different. To show that it's a continuation, the subject line could be extended with "part 2" or something like that. This solution runs in 3.6 hours. to.keep <- function(x){ keep <- function(i, env){ env$ires <- env$ires + 1 if(env$ires > env$curr.rows){ env$result <- rbind(env$result, matrix(nrow=increment, ncol=nc)) env$curr.rows <- env$curr.rows + increment } env$result[env$ires, ] <- x[i, ] } a1 <- x[, 1] a2 <- x[, 2] a3 <- x[, 3] a4 <- x[, 4] nc <- ncol(x) increment <- 1000 e <- new.env() e$curr.rows <- increment e$result <- matrix(nrow=e$curr.rows, ncol=nc) e$ires <- 0 for(i in seq_len(nrow(x))){ yes <- x[i, 1] >= a1 | x[i, 2] >= a2 | x[i, 3] <= a3 | x[i, 4] >= a4 if(all(yes)) keep(i, e) } e$result[seq_len(e$ires), 1:nc] } # Now the timing. set.seed(3971) nc <- 26 Enes <- seq(from=1e3, to=1e4, by=1e3) tm <- numeric(length(Enes)) i <- 0 for(n in Enes){ i <- i + 1 N <- nc*n m <- matrix(sample(0:9, N, TRUE), ncol=nc) tm[i] <- system.time(kp <- to.keep(m))[3] } plot(Enes, tm) # quadratic behavior fit <- lm(tm ~ Enes + I(Enes^2)) (secs <- predict(fit, newdata=data.frame(Enes=503028))) secs/60/60 # 3.6 hours Hope this helps, Rui Barradas Em 21-07-2012 13:26, wwreith escreveu: next for loop question. I need a loop that removes a row from a matrix if it is worse in positions 1,2,3,4 than another row in the matrix. right now my matrix is 503028x26. Rule to define worse position1 is smaller, position2 is smaller, position3 is higher, and position4 is smaller Example: row1: 1, 10, 3, 3 row2: 3, 7, 5, 2 row2 is not worse than row1 since it is "better" in position 1, eventhough it is worse in all other positions. row3: 2,5,7,1 row3 however is worse than row2 and should be removed from the matrix. Any ideas? Should I break this into pieces or do it all at once? Is there something faster than a loop? My current loops takes well over 24 hours to run. m<-matrix(0,1,24) for(i in 1:n) { a<-matrix(x[i,1:4],1,4) j=1 nn<-nrow(m) counter<-0 while(j<=nn) { if(a[1]>m[j,1] && a[2]>m[j,2] && a[3]>m[j,4] && a[4]min(m[,1]) || a[3]>min(m[,3]) || a[4]>min(m[,4]) || a[5]http://r.789695.n4.nabble.com/Speeding-up-a-loop-tp4637201p4637305.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] overlay contourplot with labels over spplot with color regions?
Martin Ivanov abv.bg> writes: > > Dear R users, > > I have the following problem. I plot a SpatialPixelsDataFrame object with spplot and I need to add a contourplot > of another spatial variable. ... You may find that posting to R-sig-geo will help. It would also help to include a self-contained example, say using the built-in meuse.grid data set. Roger > > I am already out of ideas. I am looking forward to Your replies. Any suggestions will be appreciated. > > Best regards, > > Martin > > __ 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] alternative to rbind for data.table
You need to preallocate. [See the R Inferno] n <- 1 dt <- as.data.table(matrix(0, nrow = n, ncol = 5)) for(i in seq_len(n)){ dt[i, ] <- ### Whatever } Note that this *might* be somewhat trickier with data.tables and their fancy indexing. It might be easier to simply assign into the matrix and then coerce that into a data.table when you're done. Alternatively, if your simulation can be run in parallel, you might try something like this: library(parallel) # Set up back end if needed do.call(rbind, mclapply(seq_len(n), function(n) do_simulation())) Best, Michael On Sat, Jul 21, 2012 at 6:21 AM, Christof Kluß wrote: > Hi > > I want to add a row to a "data.table" in each round of a for loop. > "rbind" seems to be a inefficient way to implement this. > > How would you do this? The "slow" solution: > > library(data.table) > Rprof("test.out") > dt <- data.table() > > for (i in (1:1)) { > # algorithm that generates a list with different values, > # but same key-names, each round, for example > l <- list(A=1,B=2,C=3,E=4,F=5) > dt <- rbind(dt,l) # very slow :( > } > > Rprof(NULL) > summaryRprof("test.out") > > thx > Christof > > __ > 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] EM for missing data
Hello Ya. I am no expert, so I am eager to read suggestions from other people in the mailing list. But just a few pointers I am (somewhat) sure of - You can try using this package: http://cran.r-project.org/web/packages/imputation/imputation.pdf And use something like kNNImpute. KNN solving is a type of EM. In any event, an imputation based on EM is also based on some assumption of the underlying distribution of the data (observable and missing). From what I see here: http://www.youtube.com/watch?v=xEkJxl6mmQ0 It seems that the EM of SPSS often assumed a (multi?!) normal distribution of the data. Which is a stronger assumption than what knn will use. Also the function I linked to has a CV option to check how stable the imputation process is. If you are looking for more options just google R+imputation. There are numerous packages and functions for this. Good luck, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Sat, Jul 21, 2012 at 2:55 PM, ya wrote: > Hi list, > > I am wondering if there is a way to use EM algorithm to handle missing > data and get a completed data set in R? > > I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated > value for the missing data, and then the completed dataset can be saved and > used for further analysis. But I have not found a way to get the a > completed data set like this in R or SAS. With Amelia or MICE, the missing > data set were imputed a couple of times, and the new imputed datasets were > not combined. I understand that the parameter estimation can still be done > in the way of combination of estimates from each imputed data set, but it > would be more convenient to have a combined dataset to do some analysis, > for example, ANOVA with IVs having more than two categories. In this case, > the only way to get the main effect of the whole IV is to estimate > parameters in a single data set(as far as I know). If the separated imputed > data sets were used, then the main effect showed in the result were for > each category of the IV, respectively. I figured sometimes the readers and > reviewers would like to see how bi! > g the effect for the whole IV instead of the effect of each category of > that IV. > > This is one of the reasons I can not fully move to R from SPSS. So any > suggestions? > > Thank you very much. > > > > > ya > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] FIML using lavaan returns zeroes for coefficients
On 07/20/2012 10:35 PM, Andrew Miles wrote: Hello! I am trying to reproduce (for a publication) analyses that I ran several months ago using lavaan, I'm not sure which version, probably 0.4-12. A sample model is given below: pathmod='mh30days.log.w2 ~ mh30days.log + joingroup + leavegroup + alwaysgroup + grp.partic.w2 + black + age + bivoc + moved.conf + local.noretired + retired + ds + ministrytime + hrswork + nomoralescore.c + negint.c + cong.conflict.c + nomoraleXjoin + nomoraleXleave + nomoraleXalways + negintXjoin + negintXleave + negintXalways + conflictXjoin + conflictXleave + conflictXalways ' mod1 = sem(pathmod, data=sampledat, missing="fiml", se="robust") At the time, the model ran fine. Now, using version 0.4-14, the model returns all 0's for coefficients. What happened is that since 0.4-14, lavaan tries to 'detect' models that are just univariate regression, and internally calls lm.fit, instead of the lavaan estimation engine, at least when the missing="ml" argument is NOT used. (BTW, I fail to understand why you would use lavaan if you just want to fit a univariate regression). When missing="ml" is used, lavaan normally checks if you have fixed x covariates (which you do), and if fixed.x=TRUE (which is the default). In 0.4, lavaan internally switches to fixed.x=FALSE (which implicitly assumes that all your predictors are continuous, but I assume you would not using missing="ml" otherwise). Unfortunately, for the 'special' case of univariate regression, it fails to do this. This behavior will likely change in 0.5, where, by default, only endogenous/dependent variables will be handled by missing="ml", not exogenous 'x' covariates. To fix it: simply add the fixed.x=FALSE argument, or revert to 0.4-12 to get the old behavior. Hope this helps, Yves. http://lavaan.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] Speeding up a loop
Any chance I could ask for an idiots guide for function to.keep(x). I understand how to use it but not what some of the lines are doing. Comments would be extremely helpful. -- View this message in context: http://r.789695.n4.nabble.com/Speeding-up-a-loop-tp4637201p4637316.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] Speeding up a loop
Ok, sorry, I should have included some comments. The function is divided in three parts, 1. intro, 2. decision, 3. keep rows. Part 3 is the function keep(), internal to to.keep(). Let's start with 1. 1. Setup some variables first. 1.a) The variables 'a'. If the input object 'x' is a matrix this doesn't give a great speed-up but if 'x' is a data.frame, extraction is time consuming. So, do this once only, at the beginning. 1.b) The new environment. This is because my first version would need to change values declared outside the internal function. This can be done with the global assignment operator, <<-, but this pratice should be avoided, it's easy to mess things up. Note that all the variables changed inside the internal function are in this new environment, 'e'. In particular note that 'result' is initialized with 1000 rows. 2. The loop. This is where we decide if we want to keep that row. I have negated the condition from an original 'no'. The 'no' condition: a1[i] < a1 & a2[i] < a2 & a3[i] > a3 & a4[i] < a4 Then the test would be: if(any(no)) dont_keep else keep. # pseudo-code Not in pseudo-code: if( all( !no ) ) keep(i, e) The down side of this is that the original is more readable. 3. The internal function, keep(). Considering the small number of rows I have used for tests, e$result was initialized to 1e3. With 5e5 lines I would increase this number to 1e5. First, the funcion updates the [row number] pointer into 'result' and checks if we are at a 'result' limit. If yes, make it bigger by e$increment [ == 1e3 ] rows. Then just assign row i from matrix/df 'x' to the appropriate row of e$result. The reason why we need the environment is because on function return, all but the returned value is lost. We could return a list with saved values of ires, curr.rows, result, and return the list. But this would complicate and slow things down. Assign, update and reassign. Messy. Environments can help keep it "simple", in the sense of to keep together what is meant to be used together. And now I hope there is not an overdose of comments :) Rui Barradas Em 21-07-2012 18:37, wwreith escreveu: Any chance I could ask for an idiots guide for function to.keep(x). I understand how to use it but not what some of the lines are doing. Comments would be extremely helpful. -- View this message in context: http://r.789695.n4.nabble.com/Speeding-up-a-loop-tp4637201p4637316.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] combined EM dataset for missing data?
It is not clear what you actually want. Do you want to save imputed data sets for further analysis? That is pretty simple. What do you mean by combining the data sets? Are you confusing single imputation with multiple imputation? In addition to the packages you mentioned, there are many others. See the Official Statistics & Survey Methodology Task View: http://cran.r-project.org/web/views/OfficialStatistics.html -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of ya > Sent: Saturday, July 21, 2012 6:59 AM > To: r-help > Subject: [R] combined EM dataset for missing data? > > > Hi list, > > I am wondering if there is a way to use EM algorithm to handle missing > data and get a completed data set in R? > > I usually do it in SPSS because EM in SPSS kind of "fill in" the > estimated value for the missing data, and then the completed dataset > can be saved and used for further analysis. But I have not found a way > to get the a completed data set like this in R or SAS. With Amelia or > MICE, the missing data set were imputed a couple of times, and the new > imputed datasets were not combined. I understand that the parameter > estimation can still be done in the way of combination of estimates > from each imputed data set, but it would be more convenient to have a > combined dataset to do some analysis, for example, ANOVA with IVs > having more than two categories. In this case, the only way to get the > main effect of the whole IV is to estimate parameters in a single data > set(as far as I know). If the separated imputed data sets were used, > then the main effect showed in the result were for each category of the > IV, respectively. I figured sometimes the readers and reviewers would > like to see how bi! > g the effect for the whole IV instead of the effect of each category > of that IV. > > This is one of the reasons I can not fully move to R from SPSS. So any > suggestions? > > Thank you very much. > > > > > ya > [[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] contour line labels in trellis contourplot
Hello, In the classical function "contour" labels are drawn so that each contour line is broken at the place of the label, so that the label does not overlap the line. In the trellis contoourplot the labels are placed beside or over the line, controlled by the label.style parameter, but I could not find an option that would place the labels just as in the classical contour: breaking the contour line to make place for the label. Have You got any ideas how breaking the contours to make place for the labels could be achieved in a trellis contourplot? Best regards, Martin __ 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] EM for missing data
The EM algorithm does not impute missing data, rather it estimates parameters when you have missing data (those parameters can then be used to impute the missing values, but that is separate from the EM algorithm). If you create a dataset that has missing values imputed (a single time) and then analyze that dataset as if there were no missing data then your results will be wrong. The better approach is multiple imputation (and there are packages including MICE to do this) where more than one new dataset is imputed (including error on the imputed missing values), then each of the imputed datasets is analyzed (don't look at the results yet, they are still each wrong), then the analyses are combined to give a correct answer (well as correct as any statistical procedure is, approximate is probably the better term). Though this of course is assuming that your assumptions are reasonable. If SPSS really gives you a single imputed dataset after running EM for you to analyze using other tools then my opinion of SPSS will go down. The reason that you probably have not found a way to do this in SAS or R is because they are useful tools that try to not make it easy to do the wrong thing. On Sat, Jul 21, 2012 at 5:55 AM, ya wrote: > Hi list, > > I am wondering if there is a way to use EM algorithm to handle missing data > and get a completed data set in R? > > I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated > value for the missing data, and then the completed dataset can be saved and > used for further analysis. But I have not found a way to get the a completed > data set like this in R or SAS. With Amelia or MICE, the missing data set > were imputed a couple of times, and the new imputed datasets were not > combined. I understand that the parameter estimation can still be done in the > way of combination of estimates from each imputed data set, but it would be > more convenient to have a combined dataset to do some analysis, for example, > ANOVA with IVs having more than two categories. In this case, the only way to > get the main effect of the whole IV is to estimate parameters in a single > data set(as far as I know). If the separated imputed data sets were used, > then the main effect showed in the result were for each category of the IV, > respectively. I figured sometimes the readers and reviewers would like to see > how ! bi! > g the effect for the whole IV instead of the effect of each category of that > IV. > > This is one of the reasons I can not fully move to R from SPSS. So any > suggestions? > > Thank you very much. > > > > > ya > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ 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 questions re: the use of lattice
Dear friends, I have two questions regarding the use of lattice. First some code: ## begin code z <- cbind(rep(c("BIC", "ICL", "s_v", "Q_v", "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", "s_haar"), each = 250), rep(c(5, 10, 20, 30, 50), each = 50)) z <- rbind(cbind(z, 0), cbind(z, 20), cbind(z, 40)) z <- cbind(z, rnorm(n = nrow(z))) z <- as.data.frame(z) names(z) <- c("Method", "sigma", "INU", "Error") sigma <- as.numeric(levels(z$sigma)) sigmaExprList <- lapply(sigma, function(s) bquote(italic(sigma) == . (s))) sigmaExpr <- as.expression(sigmaExprList) bwplot(Error~Method | sigma, data = z[z[,"INU"] == 0,],scales=list (rot=90), horiz = F, xlab = "Method", ylab = "Relative Error", strip = function(which.given, which.panel, var.name, strip.levels = FALSE, strip.names = TRUE, ...) { strip.default(which.given, which.panel, var.name = sigmaExpr[which.panel], strip.levels = FALSE, strip.names = TRUE, ...) }, layout = c(5,1), col = "red") ## end code Question 1: how do I "force" the display of the "Method" in the plotting to be in the same order (i.e., in the order of "BIC", "ICL", "s_v", "Q_v", "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", "s_haar") as the input. As you may notice, it puts them in its own merry order (I suspect in ascii alphabetical order, but that conjecture is based entirely on my very few sample attempts). Question 2: I want to have 3x5 plots of the respective boxplots. Something like: Error ~ Method | sigma + INU? But I want the labels for the sigma and the INU to be only in the column and the rows (vertically here) as appropriate, in order to save plotting space. How do I go about doing this? Please reply through the mailing list so that others may also benefit. In any case, many thanks again for reading and for any help and pointers! Best wishes, Ranjan -- Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. For those needing to send personal or professional e-mail, please use appropriate addresses. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] combined EM dataset for missing data?
Thanks Bert. So far I have not found any way that output a single data set which combines all the imputed data sets (say, 50 imputed data sets). Probably I missed something, but could you share some information about it, maybe a link? Thank you very much for helping. ya From: Bert Gunter Date: 2012-07-21 16:58 To: xinxi813 CC: r-help Subject: Re: [R] combined EM dataset for missing data? Search yourself! 1. Google on "Impute missing data in R" 2. See the ?RSiteSearch function 3. Go to Rseek.org and enter in keywords. 4. Download and install the sos package and use its search functionality. R has multiple packages and functions with multiple approaches to missing data imputation. Choose what you need. -- Bert On Sat, Jul 21, 2012 at 4:58 AM, ya wrote: > > Hi list, > > I am wondering if there is a way to use EM algorithm to handle missing data > and get a completed data set in R? > > I usually do it in SPSS because EM in SPSS kind of "fill in" the estimated > value for the missing data, and then the completed dataset can be saved and > used for further analysis. But I have not found a way to get the a completed > data set like this in R or SAS. With Amelia or MICE, the missing data set > were imputed a couple of times, and the new imputed datasets were not > combined. I understand that the parameter estimation can still be done in the > way of combination of estimates from each imputed data set, but it would be > more convenient to have a combined dataset to do some analysis, for example, > ANOVA with IVs having more than two categories. In this case, the only way to > get the main effect of the whole IV is to estimate parameters in a single > data set(as far as I know). If the separated imputed data sets were used, > then the main effect showed in the result were for each category of the IV, > respectively. I figured sometimes the readers and reviewers would like to see > how ! bi! > g the effect for the whole IV instead of the effect of each category of that > IV. > > This is one of the reasons I can not fully move to R from SPSS. So any > suggestions? > > Thank you very much. > > > > > ya > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] car::Anova - Can it be used for ANCOVA with repeated-measures factors.
Dear list, I would like to run an ANCOVA using car::Anova with repeated measures factors, but I can't figure out how to do it. My (between-subjects) covariate always interacts with my within-subject factors. As far as I understand ANCOVA, covariates usually do not interact with the effects of interest but are simply additive (or am I wrong here?). More specifically, I can add a covariate as a factor to the between-subjects part when fitting the MLM that behaves like expected (i.e., does not interact with the other factors), but when calling Anova on the model, I don't know how I can specify the between-within design (i.e., which parts of the model should interact with the repeated measures factors). As far as I understand it, neither the idesign, icontrasts or imatrix arguments, nor the linearHypothesis function can specify the within-between design (as far as I get it they all specify the within or intra-subject design, see John Fox's slides from User 2011: http://web.warwick.ac.uk/statsdept/useR-2011/TalkSlides/Contributed/17Aug_1705_FocusV_4-Multivariate_1-Fox.pdf). If this it is not possible using car::Anova, is there another way to achiebve what I want or is it plainly wrong? I have the feeling that using R's "New Functions for Multivariate Analysis" (Dalgaard, 2007, R News) this could be possible, but some advice on how, would be greatly appreciated, as this does not seem to be the most straight forward way. Below is an example using the car::OBrienKaiser dataset adding an age covariate. The example is merely an adoption from ?Anova with miniml changes and includes e.g. age:phase:hour which I don't want to have. Note that I posted this question to stackoverflow two days ago (http://stackoverflow.com/q/11567446/289572) and did not receive any responses. Please excuse my "crossposting", but I think R-help may be the better place. Best, Henrik PS: I know that the posting guide says "No questions about contributed packages" but there are some questions about car on R-help, so I thought this would be the correct place. ## Example follows # require(car) set.seed(1) n.OBrienKaiser <- within(OBrienKaiser, age <- sample(18:35, size = 16, replace = TRUE)) phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)), levels=c("pretest", "posttest", "followup")) hour <- ordered(rep(1:5, 3)) idata <- data.frame(phase, hour) mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, post.1, post.2, post.3, post.4, post.5, fup.1, fup.2, fup.3, fup.4, fup.5) ~ treatment * gender + age, data=n.OBrienKaiser) (av.ok <- Anova(mod.ok, idata=idata, idesign=~phase*hour, type = 3)) # Type II Repeated Measures MANOVA Tests: Pillai test statistic # Df test stat approx F num Df den Df Pr(>F) # (Intercept) 1 0.971299.9 1 9 0.00032 *** # treatment2 0.492 4.4 2 9 0.04726 * # gender 1 0.193 2.1 1 9 0.17700 # age 1 0.045 0.4 1 9 0.53351 # treatment:gender 2 0.389 2.9 2 9 0.10867 # phase1 0.855 23.6 2 8 0.00044 *** # treatment:phase 2 0.696 2.4 4 18 0.08823 . # gender:phase 1 0.079 0.3 2 8 0.71944 # age:phase1 0.140 0.7 2 8 0.54603 # treatment:gender:phase 2 0.305 0.8 4 18 0.53450 # hour 1 0.939 23.3 4 6 0.00085 *** # treatment:hour 2 0.346 0.4 8 14 0.92192 # gender:hour 1 0.286 0.6 4 6 0.67579 # age:hour 1 0.262 0.5 4 6 0.71800 # treatment:gender:hour2 0.539 0.6 8 14 0.72919 # phase:hour 1 0.663 0.5 8 2 0.80707 # treatment:phase:hour 2 0.893 0.3 16 6 0.97400 # gender:phase:hour1 0.700 0.6 8 2 0.76021 # age:phase:hour 1 0.813 1.1 8 2 0.56210 # treatment:gender:phase:hour 2 1.003 0.4 16 6 0.94434 # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 -- Dipl. Psych. Henrik Singmann PhD Student Albert-Ludwigs-Universität Freiburg http://www.psychologie.uni-freiburg.de/Members/singmann __ 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] Control y axis
Hi, No problem. I was gettting -8 and 6 for the code I sent to you. I am using R 2.15. This code gets -8 and 8 for the y axis: x<-1:17 > y<- -8:8 > plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,axes=FALSE) > axis(1,at=c(0,2,4,6,8,10,12,14,16,18)) > axis(2,at=c(-8,-6,-4,-2,0,2,4,6,8,10)) A.K. From: Stefanie Wind To: arun Sent: Saturday, July 21, 2012 9:48 AM Subject: Re: [R] Control y axis Nevermind - got it this way: plot(x, y, type ="o", xlab="Panelist", ylab="T value", lwd=1.5, xlim=c(1,14), ylim=c(-8,8), axes=FALSE)axis(1,at=c(0,2,4,6,8,10,12,14,16)) axis(2,at=c(-10,-8,-6,-4,-2,0,2,4,6,8,10)) Thanks for your response yesterday! On Sat, Jul 21, 2012 at 9:24 AM, Stefanie Wind wrote: I tried that too, but it's still truncating at -4 and 6. So strange! > > > >On Sat, Jul 21, 2012 at 12:04 AM, arun wrote: > >Hi, >> >>You can try this: >> >> x<-1:15 >> y<--8:6 >> plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,axes=FALSE) >>axis(1,at=c(0,2,4,6,8,10,12,14,16)) >>axis(2,at=c(-8,-6,-4,-2,0,2,4,6,8)) >>A.K. >> >> >> >> >> >> >>From: Stefanie Wind >>To: arun >>Sent: Friday, July 20, 2012 11:42 PM >>Subject: Re: [R] Control y axis >> >> >> >>Thanks! Do you know how I could get the values -8:8 to print on the y axis? >> >> >>On Fri, Jul 20, 2012 at 9:06 PM, arun wrote: >> >>Hi, >>> >>>The bracket after lty=1 should be replaced with comma (,). >>> x<-1:15 >>> y<--8:6 >>> plot(x, y, type ="o", xlab="Panelist", ylab="T >>>value",lwd=1.5,lty=1,xlim=range(1:14),ylim=range(-8:8),las=1) >>> >>>A.K. >>> >>> >>> >>> >>>- Original Message - >>>From: stefaniewind >>>To: r-help@r-project.org >>>Cc: >>>Sent: Friday, July 20, 2012 3:29 PM >>>Subject: [R] Control y axis >>> >>>I can't get the y axis to extend the full range that I need, which is -8 to 8 >>> >>>Here's my code. I tried using ylim, but it's still truncating at the >>>extremes in my data. >>> >>>plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,lty=1) >>>xlim=range(1:14),ylim=range(-8:8), las=1) >>> >>> >>>Any suggestions? >>> >>>Thanks! >>> >>> >>> >>>-- >>>View this message in context: >>>http://r.789695.n4.nabble.com/Control-y-axis-tp4637266.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] deactivate my account from your members
Hello, Probably, you didn't know about this option. You could deactivate your membership from Rhelp by clicking on the link below i.e (https://stat.ethz.ch/mailman/listinfo/r-help). A.K. - Original Message - From: mehdi azizi To: R-help@r-project.org Cc: Sent: Saturday, July 21, 2012 10:00 AM Subject: [R] deactivate my account from your members please don't send email to this email address: mehdi.p...@gmail.com lots of 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-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] Library control
All, 1. Is there a command that tells you what libraries are loaded? 2. How do you remove a library that has been loaded? 3. If you have loaded a library that masks previously loaded objects, how can you tell which object is being run? In Matlab, I would run "which f" to determine the location of the file f that will be run. Is there a similar procedure in R? David. -- View this message in context: http://r.789695.n4.nabble.com/Library-control-tp4637327.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] Library control
They are called packages, not libraries. On Jul 21, 2012, at 5:19 PM, darnold wrote: > All, > > 1. Is there a command that tells you what libraries are loaded? Loaded is a fluid idea** in a namespace world, but search() will let you know what's on the search path (accessible to you) > > 2. How do you remove a library that has been loaded? detach() can do it, but there might be lingering effects. The only true way is to restart your session. > > 3. If you have loaded a library that masks previously loaded objects, how > can you tell which object is being run? In Matlab, I would run "which f" to > determine the location of the file f that will be run. Is there a similar > procedure in R? > Not exactly, but take a look at conflicts() and the :: operator. Michael **Well, loading is a particular step in the package management process, but probably not what you are thinking of. > David. > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Library-control-tp4637327.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] two questions re: the use of lattice
Answer to you first question, try this at the start of bwplot to specify ordering: bwplot(Error~factor(Method, levels = unique(Method)) On Sat, Jul 21, 2012 at 2:42 PM, Ranjan Maitra wrote: > Dear friends, > > I have two questions regarding the use of lattice. First some code: > > > ## begin code > > z <- cbind(rep(c("BIC", "ICL", "s_v", "Q_v", "sig-q", > "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", > "s_haar"), each = 250), rep(c(5, 10, 20, 30, 50), each = 50)) > z <- rbind(cbind(z, 0), cbind(z, 20), cbind(z, 40)) > z <- cbind(z, rnorm(n = nrow(z))) > z <- as.data.frame(z) > names(z) <- c("Method", "sigma", "INU", "Error") > sigma <- as.numeric(levels(z$sigma)) > sigmaExprList <- lapply(sigma, function(s) bquote(italic(sigma) == . > (s))) sigmaExpr <- as.expression(sigmaExprList) > bwplot(Error~Method | sigma, data = z[z[,"INU"] == 0,],scales=list > (rot=90), horiz = F, xlab = "Method", ylab = "Relative Error", >strip = function(which.given, which.panel, var.name, > strip.levels = FALSE, > strip.names = TRUE, ...) { > strip.default(which.given, which.panel, >var.name = sigmaExpr[which.panel], >strip.levels = FALSE, >strip.names = TRUE, ...) > }, > layout = c(5,1), col = "red") > > > ## end code > > Question 1: how do I "force" the display of the "Method" in the > plotting to be in the same order (i.e., in the order of "BIC", "ICL", > "s_v", "Q_v", "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", > "s_haar") as the input. As you may notice, it puts them in its own > merry order (I suspect in ascii alphabetical order, but that conjecture > is based entirely on my very few sample attempts). > > Question 2: I want to have 3x5 plots of the respective boxplots. > Something like: > Error ~ Method | sigma + INU? > But I want the labels for the sigma and the INU to be only in the > column and the rows (vertically here) as appropriate, in order to save > plotting space. How do I go about doing this? > > Please reply through the mailing list so that others may also benefit. > In any case, many thanks again for reading and for any help and > pointers! > > Best wishes, > Ranjan > > > -- > Important Notice: This mailbox is ignored: e-mails are set to be > deleted on receipt. For those needing to send personal or professional > e-mail, please use appropriate addresses. > > > FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your > desktop! > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Control y axis
Using x/yaxp also works: plot(x, y, type ="o", xlab="Panelist", ylab="T value", lwd=1.5, xaxp=c(0, 18, 9), yaxp=c(-8, 8, 8), las=1) -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of arun > Sent: Saturday, July 21, 2012 2:16 PM > To: Stefanie Wind > Cc: R help > Subject: Re: [R] Control y axis > > Hi, > No problem. > > I was gettting -8 and 6 for the code I sent to you. I am using R > 2.15. > > > This code gets -8 and 8 for the y axis: > x<-1:17 > > y<- -8:8 > > plot(x, y, type ="o", xlab="Panelist", ylab="T > value",lwd=1.5,axes=FALSE) > > axis(1,at=c(0,2,4,6,8,10,12,14,16,18)) > > axis(2,at=c(-8,-6,-4,-2,0,2,4,6,8,10)) > A.K. > > > > > > From: Stefanie Wind > To: arun > Sent: Saturday, July 21, 2012 9:48 AM > Subject: Re: [R] Control y axis > > > Nevermind - got it this way: > > plot(x, y, type ="o", xlab="Panelist", ylab="T value", lwd=1.5, > xlim=c(1,14), ylim=c(- > 8,8), axes=FALSE)axis(1,at=c(0,2,4,6,8,10,12,14,16)) axis(2,at=c(-10,- > 8,-6,-4,-2,0,2,4,6,8,10)) > > Thanks for your response yesterday! > > > On Sat, Jul 21, 2012 at 9:24 AM, Stefanie Wind > wrote: > > I tried that too, but it's still truncating at -4 and 6. So strange! > > > > > > > >On Sat, Jul 21, 2012 at 12:04 AM, arun wrote: > > > >Hi, > >> > >>You can try this: > >> > >> x<-1:15 > >> y<--8:6 > >> plot(x, y, type ="o", xlab="Panelist", ylab="T > value",lwd=1.5,axes=FALSE) > >>axis(1,at=c(0,2,4,6,8,10,12,14,16)) > >>axis(2,at=c(-8,-6,-4,-2,0,2,4,6,8)) > >>A.K. > >> > >> > >> > >> > >> > >> > >>From: Stefanie Wind > >>To: arun > >>Sent: Friday, July 20, 2012 11:42 PM > >>Subject: Re: [R] Control y axis > >> > >> > >> > >>Thanks! Do you know how I could get the values -8:8 to print on the y > axis? > >> > >> > >>On Fri, Jul 20, 2012 at 9:06 PM, arun wrote: > >> > >>Hi, > >>> > >>>The bracket after lty=1 should be replaced with comma (,). > >>> x<-1:15 > >>> y<--8:6 > >>> plot(x, y, type ="o", xlab="Panelist", ylab="T > value",lwd=1.5,lty=1,xlim=range(1:14),ylim=range(-8:8),las=1) > >>> > >>>A.K. > >>> > >>> > >>> > >>> > >>>- Original Message - > >>>From: stefaniewind > >>>To: r-help@r-project.org > >>>Cc: > >>>Sent: Friday, July 20, 2012 3:29 PM > >>>Subject: [R] Control y axis > >>> > >>>I can't get the y axis to extend the full range that I need, which > is -8 to 8 > >>> > >>>Here's my code. I tried using ylim, but it's still truncating at the > >>>extremes in my data. > >>> > >>>plot(x, y, type ="o", xlab="Panelist", ylab="T value",lwd=1.5,lty=1) > >>>xlim=range(1:14),ylim=range(-8:8), las=1) > >>> > >>> > >>>Any suggestions? > >>> > >>>Thanks! > >>> > >>> > >>> > >>>-- > >>>View this message in context: http://r.789695.n4.nabble.com/Control- > y-axis-tp4637266.html > >>>Sent from the R help mailing list archive at Nabble.com. > >>> > >>>__ > >>>R-help@r-project.org mailing list > >>>https://stat.ethz.ch/mailman/listinfo/r-help > >>>PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > >>>and provide commented, minimal, self-contained, reproducible code. > >>> > >>> > >> > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-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] rhsape2 bug?
All, I believe I am running the latest version of rshape2 (1.2.1). But this code: library(reshape2) tmp <- melt(smiths, id.vars=1:2, measure.vars=c("age","weight","height"), variable.name="myvars", value.name="myvals" ) names(tmp) Produces this output: > names(tmp) [1] "subject" "time" "variable" "value" So you can see that these lines of code don't work: variable.name="myvars", value.name="myvals" Is this a bug? David -- View this message in context: http://r.789695.n4.nabble.com/rhsape2-bug-tp4637331.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] memory size
Dear R community, I'm running "a mlogit" function with a very large data set. Since the data size is so large, I got the Error: Error: cannot allocate vector of size 5.4 Mb In addition: Warning messages: 1: In mapply("*", X, P, SIMPLIFY = FALSE) : Reached total allocation of 16340Mb: see help(memory.size) 2: In mapply("*", X, P, SIMPLIFY = FALSE) : Reached total allocation of 16340Mb: see help(memory.size) 3: In mapply("*", X, P, SIMPLIFY = FALSE) : Reached total allocation of 16340Mb: see help(memory.size) 4: In mapply("*", X, P, SIMPLIFY = FALSE) : Reached total allocation of 16340Mb: see help(memory.size) I'm using win7 and my computer has 16G memory. Is there a way that I can make R use the memory more efficiently? Thanks! Gary [[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] rhsape2 bug?
Hi David, Your example works as expected for me (see sessionInfo below). What version of R are you using? What other packages are loaded? R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reshape2_1.2.1 loaded via a namespace (and not attached): [1] plyr_1.7.1 stringr_0.6 tools_2.15.1 Best, Ista On Sat, Jul 21, 2012 at 7:06 PM, darnold wrote: > All, > > I believe I am running the latest version of rshape2 (1.2.1). But this code: > > library(reshape2) > > tmp <- melt(smiths, > id.vars=1:2, > measure.vars=c("age","weight","height"), > variable.name="myvars", > value.name="myvals" > ) > > names(tmp) > > Produces this output: > >> names(tmp) > [1] "subject" "time" "variable" "value" > > So you can see that these lines of code don't work: > > variable.name="myvars", > value.name="myvals" > > Is this a bug? > > David > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/rhsape2-bug-tp4637331.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] two questions re: the use of lattice
Run this before the bwplot() command: z$Method <- factor(z$Method, levels = c("BIC", "ICL", "s_v", "Q_v", "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", "s_haar")) I don't have an answer for the 2nd question. Seems like it must be possible. -- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of jim holtman > Sent: Saturday, July 21, 2012 5:57 PM > To: Ranjan Maitra > Cc: r-help@r-project.org > Subject: Re: [R] two questions re: the use of lattice > > Answer to you first question, try this at the start of bwplot to > specify ordering: > > bwplot(Error~factor(Method, levels = unique(Method)) > > On Sat, Jul 21, 2012 at 2:42 PM, Ranjan Maitra > wrote: > > Dear friends, > > > > I have two questions regarding the use of lattice. First some code: > > > > > > ## begin code > > > > z <- cbind(rep(c("BIC", "ICL", "s_v", "Q_v", "sig-q", > > "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", > > "s_haar"), each = 250), rep(c(5, 10, 20, 30, 50), each = 50)) > > z <- rbind(cbind(z, 0), cbind(z, 20), cbind(z, 40)) > > z <- cbind(z, rnorm(n = nrow(z))) > > z <- as.data.frame(z) > > names(z) <- c("Method", "sigma", "INU", "Error") > > sigma <- as.numeric(levels(z$sigma)) > > sigmaExprList <- lapply(sigma, function(s) bquote(italic(sigma) == . > > (s))) sigmaExpr <- as.expression(sigmaExprList) > > bwplot(Error~Method | sigma, data = z[z[,"INU"] == 0,],scales=list > > (rot=90), horiz = F, xlab = "Method", ylab = "Relative Error", > >strip = function(which.given, which.panel, var.name, > > strip.levels = FALSE, > > strip.names = TRUE, ...) { > > strip.default(which.given, which.panel, > >var.name = sigmaExpr[which.panel], > >strip.levels = FALSE, > >strip.names = TRUE, ...) > > }, > > layout = c(5,1), col = "red") > > > > > > ## end code > > > > Question 1: how do I "force" the display of the "Method" in the > > plotting to be in the same order (i.e., in the order of "BIC", > "ICL", > > "s_v", "Q_v", "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", > > "s_haar") as the input. As you may notice, it puts them in its own > > merry order (I suspect in ascii alphabetical order, but that > conjecture > > is based entirely on my very few sample attempts). > > > > Question 2: I want to have 3x5 plots of the respective boxplots. > > Something like: > > Error ~ Method | sigma + INU? > > But I want the labels for the sigma and the INU to be only in the > > column and the rows (vertically here) as appropriate, in order to > save > > plotting space. How do I go about doing this? > > > > Please reply through the mailing list so that others may also > benefit. > > In any case, many thanks again for reading and for any help and > > pointers! > > > > Best wishes, > > Ranjan > > > > > > -- > > Important Notice: This mailbox is ignored: e-mails are set to be > > deleted on receipt. For those needing to send personal or > professional > > e-mail, please use appropriate addresses. > > > > > > FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas > on your desktop! > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > -- > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-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] rhsape2 bug?
Ista, You are correct. > search() [1] ".GlobalEnv""package:reshape" "package:plyr" [4] "package:reshape2" "tools:rstudio" "package:stats" [7] "package:graphics" "package:grDevices" "package:utils" [10] "package:datasets" "package:methods" "Autoloads" [13] "package:base" Thanks. D. -- View this message in context: http://r.789695.n4.nabble.com/rhsape2-bug-tp4637331p4637337.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] two questions re: the use of lattice
Take a look at useOuterStrips() in package latticeExtra. --- David > -Original Message- > From: David L Carlson [mailto:dcarl...@tamu.edu] > Sent: Saturday, July 21, 2012 6:51 PM > To: 'jim holtman'; 'Ranjan Maitra' > Cc: 'r-help@r-project.org' > Subject: RE: [R] two questions re: the use of lattice > > Run this before the bwplot() command: > > z$Method <- factor(z$Method, levels = c("BIC", "ICL", "s_v", "Q_v", > "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", "s_la8", "s_haar")) > > I don't have an answer for the 2nd question. Seems like it must be > possible. > > -- > David L Carlson > Associate Professor of Anthropology > Texas A&M University > College Station, TX 77843-4352 > > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org] On Behalf Of jim holtman > > Sent: Saturday, July 21, 2012 5:57 PM > > To: Ranjan Maitra > > Cc: r-help@r-project.org > > Subject: Re: [R] two questions re: the use of lattice > > > > Answer to you first question, try this at the start of bwplot to > > specify ordering: > > > > bwplot(Error~factor(Method, levels = unique(Method)) > > > > On Sat, Jul 21, 2012 at 2:42 PM, Ranjan Maitra > > wrote: > > > Dear friends, > > > > > > I have two questions regarding the use of lattice. First some code: > > > > > > > > > ## begin code > > > > > > z <- cbind(rep(c("BIC", "ICL", "s_v", "Q_v", "sig-q", > > > "s_lsk", "s_lML", "s_mlsk", "s_mlML", > "s_la8", > > > "s_haar"), each = 250), rep(c(5, 10, 20, 30, 50), each = 50)) > > > z <- rbind(cbind(z, 0), cbind(z, 20), cbind(z, 40)) > > > z <- cbind(z, rnorm(n = nrow(z))) > > > z <- as.data.frame(z) > > > names(z) <- c("Method", "sigma", "INU", "Error") > > > sigma <- as.numeric(levels(z$sigma)) > > > sigmaExprList <- lapply(sigma, function(s) bquote(italic(sigma) == > . > > > (s))) sigmaExpr <- as.expression(sigmaExprList) > > > bwplot(Error~Method | sigma, data = z[z[,"INU"] == 0,],scales=list > > > (rot=90), horiz = F, xlab = "Method", ylab = "Relative Error", > > >strip = function(which.given, which.panel, var.name, > > > strip.levels = FALSE, > > > strip.names = TRUE, ...) { > > > strip.default(which.given, which.panel, > > >var.name = sigmaExpr[which.panel], > > >strip.levels = FALSE, > > >strip.names = TRUE, ...) > > > }, > > > layout = c(5,1), col = "red") > > > > > > > > > ## end code > > > > > > Question 1: how do I "force" the display of the "Method" in the > > > plotting to be in the same order (i.e., in the order of "BIC", > > "ICL", > > > "s_v", "Q_v", "sig-q", "s_lsk", "s_lML", "s_mlsk", "s_mlML", > "s_la8", > > > "s_haar") as the input. As you may notice, it puts them in its own > > > merry order (I suspect in ascii alphabetical order, but that > > conjecture > > > is based entirely on my very few sample attempts). > > > > > > Question 2: I want to have 3x5 plots of the respective boxplots. > > > Something like: > > > Error ~ Method | sigma + INU? > > > But I want the labels for the sigma and the INU to be only in the > > > column and the rows (vertically here) as appropriate, in order to > > save > > > plotting space. How do I go about doing this? > > > > > > Please reply through the mailing list so that others may also > > benefit. > > > In any case, many thanks again for reading and for any help and > > > pointers! > > > > > > Best wishes, > > > Ranjan > > > > > > > > > -- > > > Important Notice: This mailbox is ignored: e-mails are set to be > > > deleted on receipt. For those needing to send personal or > > professional > > > e-mail, please use appropriate addresses. > > > > > > > > > FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & > orcas > > on your desktop! > > > > > > __ > > > R-help@r-project.org mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide http://www.R-project.org/posting- > > guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > -- > > Jim Holtman > > Data Munger Guru > > > > What is the problem that you are trying to solve? > > Tell me what you want to do, not how you want to do it. > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting- > > guide.html > > and provide commented, minimal, self-contained, reproducible code. __ R-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, r
[R] Excel file Import - to Matrix format
Hi, New to R. Need a bit of help. Thanks I am trying to import data from Excel file. The package I am trying to use requires data in Matrix format. Excel -> R Matrix with the constraint that the very first column in Excel file should became the names for rows of the matrix. Example. Data has 1000 rows and 11 columns. 1st column is the names of Genes 10 coulmns of numerical data. I need to read this into R. it should be a 1000 (row) X 10 Column (Matrix) 1st column of Excel file becomes name of the rows. I am experimenting with reading as data frame (as I am unable to find any info on reading into matrix) split the data frame, etc. Thanks truly appreciate your help. What I need: http://r.789695.n4.nabble.com/file/n4637332/thisWorks2.png http://r.789695.n4.nabble.com/file/n4637332/doesNotWork1.png -- View this message in context: http://r.789695.n4.nabble.com/Excel-file-Import-to-Matrix-format-tp4637332.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] memory size
There are many possibilities, but they all begin with reading the posting guide and following the recommendations therein so we don't have to guess what your actual configuration is. However, since your first task is to read, you might consider reading the FAQs on memory use and Windows specifically so you can ask more specific questions. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Gary Dong wrote: >Dear R community, > >I'm running "a mlogit" function with a very large data set. Since the >data >size is so large, I got the Error: > >Error: cannot allocate vector of size 5.4 Mb >In addition: Warning messages: >1: In mapply("*", X, P, SIMPLIFY = FALSE) : > Reached total allocation of 16340Mb: see help(memory.size) >2: In mapply("*", X, P, SIMPLIFY = FALSE) : > Reached total allocation of 16340Mb: see help(memory.size) >3: In mapply("*", X, P, SIMPLIFY = FALSE) : > Reached total allocation of 16340Mb: see help(memory.size) >4: In mapply("*", X, P, SIMPLIFY = FALSE) : > Reached total allocation of 16340Mb: see help(memory.size) > >I'm using win7 and my computer has 16G memory. Is there a way that I >can >make R use the memory more efficiently? > >Thanks! >Gary > > [[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] Frame Column to List (conversion)
Hi, Input Format: excel file (XLS) Column 1: Gene ID (alphanumeric) Column 2 - 10 : (numeric data). inData = read.xls ( ) geneLabel = inData [ , 1] - column 1 stored in geneLabel tempData = inData [ , 2: 10] expValues = data.matrix (tempData) - convert frame into Matrix format expValues has the matrix format needed for analysis. I need to bind gene labels as . I have this data in geneLablel (extracted from data.frame) How do I convert this to a list so i can use rownames(expValues) <- ??? thanks -- View this message in context: http://r.789695.n4.nabble.com/Frame-Column-to-List-conversion-tp4637341.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] rhsape2 bug?
Hi, It works for me too. When I had reshape and reshape2 both loaded, I had the same problem. library(reshape2) tmp <- melt(smiths, id.vars=1:2, measure.vars=c("age","weight","height"), variable.name="myvars", value.name="myvals" ) names(tmp) [1] "subject" "time" "myvars" "myvals" #Now with reshape loaded. > library(reshape) Loading required package: plyr Attaching package: ‘reshape’ The following object(s) are masked from ‘package:plyr’: rename, round_any The following object(s) are masked from ‘package:reshape2’: colsplit, melt, recast tmp <- melt(smiths, id.vars=1:2, measure.vars=c("age","weight","height"), variable.name="myvars", value.name="myvals" ) > names(tmp) [1] "subject" "time" "variable" "value" A.K. - Original Message - From: darnold To: r-help@r-project.org Cc: Sent: Saturday, July 21, 2012 7:06 PM Subject: [R] rhsape2 bug? All, I believe I am running the latest version of rshape2 (1.2.1). But this code: library(reshape2) tmp <- melt(smiths, id.vars=1:2, measure.vars=c("age","weight","height"), variable.name="myvars", value.name="myvals" ) names(tmp) Produces this output: > names(tmp) [1] "subject" "time" "variable" "value" So you can see that these lines of code don't work: variable.name="myvars", value.name="myvals" Is this a bug? David -- View this message in context: http://r.789695.n4.nabble.com/rhsape2-bug-tp4637331.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] Excel file Import - to Matrix format
Hello, Try this: You can use the read.table with sep="," if it is comma separated to read the file. test1<-read.table(text=" 0.141 0.242 0.342 0.224 0.342 0.334 0.652 0.682 0.182 ",sep="",header=FALSE) #Read data test1 # V1 V2 V3 #1 0.141 0.242 0.342 #2 0.224 0.342 0.334 #3 0.652 0.682 0.182 #Convert to matrix as it is that you wanted test2<-as.matrix(test1) colnames(test2)<-NULL genelist<-c("Fkh2","Swi5","Sic1") rownames(test2)<-genelist test2 # [,1] [,2] [,3] #Fkh2 0.141 0.242 0.342 #Swi5 0.224 0.342 0.334 #Sic1 0.652 0.682 0.182 #2nd case: As in your example, test1<-read.table(text=" IMAGE:152 0.141 0.242 0.342 IMAGE:262 0.224 0.342 0.334 IMAGE:342 0.652 0.682 0.182 ",sep="",header=FALSE) test2<-as.matrix(test1[-1]) colnames(test2)<-NULL genelist<-c("Fkh2","Swi5","Sic1") rownames(test2)<-genelist test2 # [,1] [,2] [,3] #Fkh2 0.141 0.242 0.342 #Swi5 0.224 0.342 0.334 #Sic1 0.652 0.682 0.182 A.K. - Original Message - From: biostat1 To: r-help@r-project.org Cc: Sent: Saturday, July 21, 2012 7:29 PM Subject: [R] Excel file Import - to Matrix format Hi, New to R. Need a bit of help. Thanks I am trying to import data from Excel file. The package I am trying to use requires data in Matrix format. Excel -> R Matrix with the constraint that the very first column in Excel file should became the names for rows of the matrix. Example. Data has 1000 rows and 11 columns. 1st column is the names of Genes 10 coulmns of numerical data. I need to read this into R. it should be a 1000 (row) X 10 Column (Matrix) 1st column of Excel file becomes name of the rows. I am experimenting with reading as data frame (as I am unable to find any info on reading into matrix) split the data frame, etc. Thanks truly appreciate your help. What I need: http://r.789695.n4.nabble.com/file/n4637332/thisWorks2.png http://r.789695.n4.nabble.com/file/n4637332/doesNotWork1.png -- View this message in context: http://r.789695.n4.nabble.com/Excel-file-Import-to-Matrix-format-tp4637332.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.