R helpers I am getting to grips with R but came across a small problem today that I could not fix by myself. I have 3 text files, each with a single column of data. I read them in using: myData1<-scan("C:/Program Files/R/myData1.txt") myData2<-scan("C:/Program Files/R/myData2.txt") myData3<-scan("C:/Program Files/R/myData3.txt") I wanted to produce a chart with 3 boxplots of the data and used: boxplot(myData1, myData2, myData3) This worked fine so I consulted R [help(bxp)] to add some format and labels e.g. title= , xlab =, ylab= , notch=TRUE etc. I managed to figure that ok. However, I could not figure out how to get the labels myData1, myData2, and myData3 on the boxplot x-axis to denote which box was which (though I knew by looking). Can anybody help with this? I trawled through my downloaded R pdfs but could not find a way. Regards Alex Park
Hi Alex, how about, myData<-data.frame("myData1"=myData1,"myData2"=myData2,"myData3"=myData3) boxplot(myData) Nolwenn ************************************** Nolwenn Le Meur, PhD Fred Hutchinson Cancer Research Center Computational Biology 1100 Fairview Ave. N., M2-B876 P.O. Box 19024 Seattle, WA 98109-1024 On Mon, 20 Feb 2006, Alex Park wrote:> R helpers > > I am getting to grips with R but came across a small problem today that I > could not fix by myself. > > I have 3 text files, each with a single column of data. I read them in > using: > > myData1<-scan("C:/Program Files/R/myData1.txt") > myData2<-scan("C:/Program Files/R/myData2.txt") > myData3<-scan("C:/Program Files/R/myData3.txt") > > I wanted to produce a chart with 3 boxplots of the data and used: > > boxplot(myData1, myData2, myData3) > > This worked fine so I consulted R [help(bxp)] to add some format and labels > e.g. title= , xlab =, ylab= , notch=TRUE etc. I managed to figure that ok. > > However, I could not figure out how to get the labels myData1, myData2, and > myData3 on the boxplot x-axis to denote which box was which (though I knew > by looking). Can anybody help with this? > > I trawled through my downloaded R pdfs but could not find a way. > > Regards > > > Alex Park > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
On Mon, 2006-02-20 at 20:27 +0000, Alex Park wrote:> R helpers > > I am getting to grips with R but came across a small problem today that I > could not fix by myself. > > I have 3 text files, each with a single column of data. I read them in > using: > > myData1<-scan("C:/Program Files/R/myData1.txt") > myData2<-scan("C:/Program Files/R/myData2.txt") > myData3<-scan("C:/Program Files/R/myData3.txt") > > I wanted to produce a chart with 3 boxplots of the data and used: > > boxplot(myData1, myData2, myData3) > > This worked fine so I consulted R [help(bxp)] to add some format and labels > e.g. title= , xlab =, ylab= , notch=TRUE etc. I managed to figure that ok. > > However, I could not figure out how to get the labels myData1, myData2, and > myData3 on the boxplot x-axis to denote which box was which (though I knew > by looking). Can anybody help with this? > > I trawled through my downloaded R pdfs but could not find a way. > > Regards > > > Alex ParkAlex, You can use the 'names' argument to boxplot(): boxplot(myData1, myData2, myData3, names = c("myData1", "myData2", "myData")) If you want additional flexibility, note that by default (unless you change the 'at' argument), the group plots are drawn at integer axis values of 1:n, where 'n' is the number of groups. See the 'at' argument in ?boxplot. You can then use mtext() to draw further text if desired. HTH, Marc Schwartz
use: boxplot(list(myData1=myData1, myData2=myData2, myData3=myData3), main='....', xlab='...') On 2/20/06, Alex Park <alex.park1@ntlworld.com> wrote:> > R helpers > > I am getting to grips with R but came across a small problem today that I > could not fix by myself. > > I have 3 text files, each with a single column of data. I read them in > using: > > myData1<-scan("C:/Program Files/R/myData1.txt") > myData2<-scan("C:/Program Files/R/myData2.txt") > myData3<-scan("C:/Program Files/R/myData3.txt") > > I wanted to produce a chart with 3 boxplots of the data and used: > > boxplot(myData1, myData2, myData3) > > This worked fine so I consulted R [help(bxp)] to add some format and > labels > e.g. title= , xlab =, ylab= , notch=TRUE etc. I managed to figure that ok. > > However, I could not figure out how to get the labels myData1, myData2, > and > myData3 on the boxplot x-axis to denote which box was which (though I knew > by looking). Can anybody help with this? > > I trawled through my downloaded R pdfs but could not find a way. > > Regards > > > Alex Park > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What the problem you are trying to solve? [[alternative HTML version deleted]]