Re: [R] Boxplot with linear (not categorical) x-axis
Thank you. On Fri, Sep 28, 2018 at 5:34 PM William Dunlap wrote: > > Use the 'at' argument to boxplot. E.g., > > > x <- rep(c(2,4,8,16), c(5,10,20,30)) > > y <- seq_along(x) > > par(mfrow=c(2,1)) > > boxplot(y~x, at=unique(x)) > > boxplot(y~x) > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Fri, Sep 28, 2018 at 3:05 AM, Luigi Marongiu > wrote: >> >> Dear all, >> I am using boxplot to draw some data. Would be possible to have the >> X-axis linear (as in a scatter plot) instead of the standard >> categorical axis? >> The data I have is subdivided into three groups at the numerical >> values 1, 3, 5; boxplot treats these as categorical values; in fact, I >> can write my own labels simply by using the values 1, 2, 3 for the >> position of the labels as in the example. >> Thank you, >> >> >> # generate data.frames >> A = c(70, 22, 4, 21, 29, 35, 24, 20, 9, 21, >> 22, 12, 20, 21, 13, 18, 15, 3, 9, 23, >> 6, 5, 2, 24, 25, 21, 16, 0, 4, 1) >> B = c(17, 21, 70, 6, 23, 10, 8, 5, 22, 5, >> 21, 5, 19, 9, 23, 24, 11, 13, 7, 15, >> 25, 9, 13, 14, 11, 9, 12, 0, 5, 9) >> C = c(17, 8, 30, 22, 11, 32, 33, 8, 160, 11, >> 35, 7, 36, 15, 11, 25, 16, 6, 38, 19, >> 35, 30, 12, 27, 22, 32, 47, 39, 31, 26) >> X = rep(c(1, 3, 5),30*3) >> dfA <- data.frame(X, c(A, B, C)) >> names(dfA) <- c("X", "Y") >> par(mfrow=c(2,1)) >> boxplot(dfA$Y ~ dfA$X, >> ylim=c(0, 80), >> col="green", >> ylab="Y-values", >> xlab="X-values", >> main="usual X labels" >> ) >> boxplot(dfA$Y ~ dfA$X, >> ylim=c(0, 80), >> col="green", >> ylab="Y-values", >> xlab="X-values", >> main="custom X labels", >> xaxt="n" >> ) >> x.lab = c("A", "B", "C") >> x.pos = c(1, 2, 3) >> axis(side=1, at=x.pos, >> lab=x.lab, cex.axis=1) >> >> -- >> Best regards, >> Luigi >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > -- Best regards, Luigi __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot with linear (not categorical) x-axis
Use the 'at' argument to boxplot. E.g., > x <- rep(c(2,4,8,16), c(5,10,20,30)) > y <- seq_along(x) > par(mfrow=c(2,1)) > boxplot(y~x, at=unique(x)) > boxplot(y~x) Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Sep 28, 2018 at 3:05 AM, Luigi Marongiu wrote: > Dear all, > I am using boxplot to draw some data. Would be possible to have the > X-axis linear (as in a scatter plot) instead of the standard > categorical axis? > The data I have is subdivided into three groups at the numerical > values 1, 3, 5; boxplot treats these as categorical values; in fact, I > can write my own labels simply by using the values 1, 2, 3 for the > position of the labels as in the example. > Thank you, > > > # generate data.frames > A = c(70, 22, 4, 21, 29, 35, 24, 20, 9, 21, > 22, 12, 20, 21, 13, 18, 15, 3, 9, 23, > 6, 5, 2, 24, 25, 21, 16, 0, 4, 1) > B = c(17, 21, 70, 6, 23, 10, 8, 5, 22, 5, > 21, 5, 19, 9, 23, 24, 11, 13, 7, 15, > 25, 9, 13, 14, 11, 9, 12, 0, 5, 9) > C = c(17, 8, 30, 22, 11, 32, 33, 8, 160, 11, > 35, 7, 36, 15, 11, 25, 16, 6, 38, 19, > 35, 30, 12, 27, 22, 32, 47, 39, 31, 26) > X = rep(c(1, 3, 5),30*3) > dfA <- data.frame(X, c(A, B, C)) > names(dfA) <- c("X", "Y") > par(mfrow=c(2,1)) > boxplot(dfA$Y ~ dfA$X, > ylim=c(0, 80), > col="green", > ylab="Y-values", > xlab="X-values", > main="usual X labels" > ) > boxplot(dfA$Y ~ dfA$X, > ylim=c(0, 80), > col="green", > ylab="Y-values", > xlab="X-values", > main="custom X labels", > xaxt="n" > ) > x.lab = c("A", "B", "C") > x.pos = c(1, 2, 3) > axis(side=1, at=x.pos, > lab=x.lab, cex.axis=1) > > -- > Best regards, > Luigi > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot with linear (not categorical) x-axis
install.packages("HH") library(HH) system.file("demo/bwplot.examples.r", package="HH") demo("bwplot.examples", package="HH", ask=FALSE) ## your example dfA <- data.frame(X, Y=c(A, B, C)) dfA$X.factor <- factor(dfA$X) position(dfA$X.factor) <- c(1,3,5) bwplot(Y ~ X.factor, panel=panel.bwplot.intermediate.hh, data=dfA, xlim=c(0,6)) On Fri, Sep 28, 2018 at 6:05 AM, Luigi Marongiu wrote: > Dear all, > I am using boxplot to draw some data. Would be possible to have the > X-axis linear (as in a scatter plot) instead of the standard > categorical axis? > The data I have is subdivided into three groups at the numerical > values 1, 3, 5; boxplot treats these as categorical values; in fact, I > can write my own labels simply by using the values 1, 2, 3 for the > position of the labels as in the example. > Thank you, > > > # generate data.frames > A = c(70, 22, 4, 21, 29, 35, 24, 20, 9, 21, > 22, 12, 20, 21, 13, 18, 15, 3, 9, 23, > 6, 5, 2, 24, 25, 21, 16, 0, 4, 1) > B = c(17, 21, 70, 6, 23, 10, 8, 5, 22, 5, > 21, 5, 19, 9, 23, 24, 11, 13, 7, 15, > 25, 9, 13, 14, 11, 9, 12, 0, 5, 9) > C = c(17, 8, 30, 22, 11, 32, 33, 8, 160, 11, > 35, 7, 36, 15, 11, 25, 16, 6, 38, 19, > 35, 30, 12, 27, 22, 32, 47, 39, 31, 26) > X = rep(c(1, 3, 5),30*3) > dfA <- data.frame(X, c(A, B, C)) > names(dfA) <- c("X", "Y") > par(mfrow=c(2,1)) > boxplot(dfA$Y ~ dfA$X, > ylim=c(0, 80), > col="green", > ylab="Y-values", > xlab="X-values", > main="usual X labels" > ) > boxplot(dfA$Y ~ dfA$X, > ylim=c(0, 80), > col="green", > ylab="Y-values", > xlab="X-values", > main="custom X labels", > xaxt="n" > ) > x.lab = c("A", "B", "C") > x.pos = c(1, 2, 3) > axis(side=1, at=x.pos, > lab=x.lab, cex.axis=1) > > -- > Best regards, > Luigi > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot: draw outliers in colours
Hi Luigi, An easy way is to use "points" to overplot the outliers: grbxp<-boxplot(dfA$Y ~ dfA$X, ylim=c(0, 200), col="green", ylab="Y-values", xlab="X-values" ) points(grbxp$group,grbxp$out,col="green") On Fri, Sep 28, 2018 at 7:51 PM Luigi Marongiu wrote: > > Dear all, > I am trying to overlap two series of boxplots on the same graph. In > order to distinguish the outliers from one series to the other, would > be possible to colour the outliers?: instead of the standard black, is > it possible to give a chosen colour? > Thank you > > >>> > This is the example. I could not generate not normally distributed > random values (even with runif), so I had to create the values > manually and they are still a bit rough (in the real thing, the two > series are more distant), anyway this should better explain the case. > Note that the three outliers at the bottom right belong to the 'blue' > distribution and the upper outlier on the right belongs to the 'green' > distribution, so making them in blue and green colours would make > clearer their positions. > > # generate data.frames > A = c(70, 22, 4, 21, 29, 35, 24, 20, 9, 21, > 22, 12, 20, 21, 13, 18, 15, 3, 9, 23, > 6, 5, 2, 24, 25, 21, 16, 0, 4, 1) > B = c(17, 21, 70, 6, 23, 10, 8, 5, 22, 5, > 21, 5, 19, 9, 23, 24, 11, 13, 7, 15, > 25, 9, 13, 14, 11, 9, 12, 0, 5, 9) > C = c(17, 8, 30, 22, 11, 32, 33, 8, 160, 11, > 35, 7, 36, 15, 11, 25, 16, 6, 38, 19, > 35, 30, 12, 27, 22, 32, 47, 39, 31, 26) > D = c(79, 26, 8, 33, 59, 67, 60, 65, 54, 88, > 78, 105, 59, 40, 109, 81, 28, 26, 94, > 35, 10, 38, 58, 79, 58, 10, 5, 8, 4, 50) > E = c(98, 104, 101, 102, 97, 97, 97, > 100, 97, 102, 100, 103, 104, > 104, 99, 102, 100, 97, 102, 105, > 99, 105, 100, 102, 100, 115, > 112, 113, 111, 115) > G = c(105, 130, 97, 105, 113, 123, > 149, 15, 134, 148, 98, 104, > 113, 108, 209, 145, 138, 119, > 142, 129, 298, 101, 136, 129, > 148, 295, 125, 277, 107, 642) > X = rep(c(1, 3, 5),30*3) > dfA <- data.frame(X, c(A, B, C)) > dfB <- data.frame(X, c(D, E, G)) > names(dfA) <- c("X", "Y") > names(dfB) <- c("X", "Y") > > # plot > boxplot(dfA$Y ~ dfA$X, > ylim=c(0, 200), > col="green", > ylab="Y-values", > xlab="X-values" > ) > par(new=TRUE) > boxplot(dfB$Y ~ dfB$X, > ylim=c(0, 200), > col="blue", > ylab="", xlab="", > xaxt="n", yaxt="n" > ) > > > -- > Best regards, > Luigi > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot with linear (not categorical) x-axis
Dear all, I am using boxplot to draw some data. Would be possible to have the X-axis linear (as in a scatter plot) instead of the standard categorical axis? The data I have is subdivided into three groups at the numerical values 1, 3, 5; boxplot treats these as categorical values; in fact, I can write my own labels simply by using the values 1, 2, 3 for the position of the labels as in the example. Thank you, # generate data.frames A = c(70, 22, 4, 21, 29, 35, 24, 20, 9, 21, 22, 12, 20, 21, 13, 18, 15, 3, 9, 23, 6, 5, 2, 24, 25, 21, 16, 0, 4, 1) B = c(17, 21, 70, 6, 23, 10, 8, 5, 22, 5, 21, 5, 19, 9, 23, 24, 11, 13, 7, 15, 25, 9, 13, 14, 11, 9, 12, 0, 5, 9) C = c(17, 8, 30, 22, 11, 32, 33, 8, 160, 11, 35, 7, 36, 15, 11, 25, 16, 6, 38, 19, 35, 30, 12, 27, 22, 32, 47, 39, 31, 26) X = rep(c(1, 3, 5),30*3) dfA <- data.frame(X, c(A, B, C)) names(dfA) <- c("X", "Y") par(mfrow=c(2,1)) boxplot(dfA$Y ~ dfA$X, ylim=c(0, 80), col="green", ylab="Y-values", xlab="X-values", main="usual X labels" ) boxplot(dfA$Y ~ dfA$X, ylim=c(0, 80), col="green", ylab="Y-values", xlab="X-values", main="custom X labels", xaxt="n" ) x.lab = c("A", "B", "C") x.pos = c(1, 2, 3) axis(side=1, at=x.pos, lab=x.lab, cex.axis=1) -- Best regards, Luigi __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot: draw outliers in colours
Dear all, I am trying to overlap two series of boxplots on the same graph. In order to distinguish the outliers from one series to the other, would be possible to colour the outliers?: instead of the standard black, is it possible to give a chosen colour? Thank you >>> This is the example. I could not generate not normally distributed random values (even with runif), so I had to create the values manually and they are still a bit rough (in the real thing, the two series are more distant), anyway this should better explain the case. Note that the three outliers at the bottom right belong to the 'blue' distribution and the upper outlier on the right belongs to the 'green' distribution, so making them in blue and green colours would make clearer their positions. # generate data.frames A = c(70, 22, 4, 21, 29, 35, 24, 20, 9, 21, 22, 12, 20, 21, 13, 18, 15, 3, 9, 23, 6, 5, 2, 24, 25, 21, 16, 0, 4, 1) B = c(17, 21, 70, 6, 23, 10, 8, 5, 22, 5, 21, 5, 19, 9, 23, 24, 11, 13, 7, 15, 25, 9, 13, 14, 11, 9, 12, 0, 5, 9) C = c(17, 8, 30, 22, 11, 32, 33, 8, 160, 11, 35, 7, 36, 15, 11, 25, 16, 6, 38, 19, 35, 30, 12, 27, 22, 32, 47, 39, 31, 26) D = c(79, 26, 8, 33, 59, 67, 60, 65, 54, 88, 78, 105, 59, 40, 109, 81, 28, 26, 94, 35, 10, 38, 58, 79, 58, 10, 5, 8, 4, 50) E = c(98, 104, 101, 102, 97, 97, 97, 100, 97, 102, 100, 103, 104, 104, 99, 102, 100, 97, 102, 105, 99, 105, 100, 102, 100, 115, 112, 113, 111, 115) G = c(105, 130, 97, 105, 113, 123, 149, 15, 134, 148, 98, 104, 113, 108, 209, 145, 138, 119, 142, 129, 298, 101, 136, 129, 148, 295, 125, 277, 107, 642) X = rep(c(1, 3, 5),30*3) dfA <- data.frame(X, c(A, B, C)) dfB <- data.frame(X, c(D, E, G)) names(dfA) <- c("X", "Y") names(dfB) <- c("X", "Y") # plot boxplot(dfA$Y ~ dfA$X, ylim=c(0, 200), col="green", ylab="Y-values", xlab="X-values" ) par(new=TRUE) boxplot(dfB$Y ~ dfB$X, ylim=c(0, 200), col="blue", ylab="", xlab="", xaxt="n", yaxt="n" ) -- Best regards, Luigi __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] BoxPlot Adding Mean and Median Values
> Here is the code I have tried. The code has to work to be useful. including the data read - which, because it is on your D: drive, clearly can't be read.. But here are some comments and some base graphics code that should get you started; > As I mentioned below, would like to add the data labels into each box of mean > value #You'll need to calculate the mean values separately. A standard boxplot doesn't include them > AmbientTr <- read.csv("AmbientBatchbox.csv", stringsAsFactors = TRUE) #Not possible > str(AmbientTr) > summary(AmbientTr) #Not possible > install.packages("ggplot2") #Don;t need to do this every time > library(ggplot2) #And you don’t need it at all: you are using 'boxplot', which is in base graphics > boxplot(RTF~Batch,data=AmbientTr, ylim = c(0,30), main="RTF By Batch", > xlab="Batch", ylab="RTF", col ="blue") #Try assigning the result of boxplot to a variable, such as bw.data <- boxplot(RTF~Batch,data=AmbientTr, ylim = c(0,30), main="RTF By Batch", xlab="Batch", ylab="RTF", col ="blue") #Then you csan use that data to place labels etc. because boxplot returns the stats for the boxes, and the locations #are (by default) at 1:length()bw.data$names. #For example, after the above plot: with(bw.data, text(1:length(names), stats[3,], names, pos=1) #labels just below the medians #And for placing means on the plot: RTFmeans <- with(AmbientTr, tapply(RTF, batch, mean)) points(1:length(RTFmeans), RTFmeans, pch=19) text(1:length(RTFmeans), RTFmeans, paste(round(RTFmeans,0)), pos=3) #labels just above the points #... or something like that. For a ggplot equivalent, you could try the ggplot mailing list; Google it to find it. S Ellison *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] BoxPlot Adding Mean and Median Values
Hello Dave Here is the code I have tried. getwd() setwd("D:/BAP Session/Nuance") getwd() AmbientTr <- read.csv("AmbientBatchbox.csv", stringsAsFactors = TRUE) str(AmbientTr) summary(AmbientTr) install.packages("ggplot2") library(ggplot2) boxplot(RTF~Batch,data=AmbientTr, ylim = c(0,30), main="RTF By Batch", xlab="Batch", ylab="RTF", col ="blue") As I mentioned below, would like to add the data labels into each box of mean value Can you help on this what needs to be added in this code to show the data labels. On May 09, 2018, at 08:10 PM, David L Carlson <dcarl...@tamu.edu> wrote: Your snapshot did not make it to the list. Only a few types of plots are accepted, e.g. .png. But we don't need a picture as much as we need a copy of your code with enough of your data to reproduce what you are trying to do. Use dput(head(x, 15)) to print out 15 lines of your data and include all of the R code you are using. David L Carlson Department of Anthropology Texas A University College Station, TX 77843-4352 -Original Message- From: R-help <r-help-boun...@r-project.org> On Behalf Of Jayaganesh Anbuganapathy Sent: Tuesday, May 8, 2018 11:10 PM To: r-help@r-project.org Subject: [R] BoxPlot Adding Mean and Median Values Dear Team - I would like to get your help on adding the values of mean and median of RTF as mentioned in the below snapshot. Please guide me out. Thanks for your help in advance. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] BoxPlot Adding Mean and Median Values
Your snapshot did not make it to the list. Only a few types of plots are accepted, e.g. .png. But we don't need a picture as much as we need a copy of your code with enough of your data to reproduce what you are trying to do. Use dput(head(x, 15)) to print out 15 lines of your data and include all of the R code you are using. David L Carlson Department of Anthropology Texas A University College Station, TX 77843-4352 -Original Message- From: R-help <r-help-boun...@r-project.org> On Behalf Of Jayaganesh Anbuganapathy Sent: Tuesday, May 8, 2018 11:10 PM To: r-help@r-project.org Subject: [R] BoxPlot Adding Mean and Median Values Dear Team - I would like to get your help on adding the values of mean and median of RTF as mentioned in the below snapshot. Please guide me out. Thanks for your help in advance. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] BoxPlot Adding Mean and Median Values
Dear Team - I would like to get your help on adding the values of mean and median of RTF as mentioned in the below snapshot. Please guide me out. Thanks for your help in advance. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot, formula interface, and labels.
Just change the separator: data(Titanic) Titanic.df <- as.data.frame(Titanic) boxplot(Freq~Class*Sex, Titanic.df, cex.axis=.6, sep="\n") See attached .png. David L Carlson Department of Anthropology Texas A University College Station, TX 77843-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Thursday, September 28, 2017 12:27 PM To: Ed Siefker <ebs15...@gmail.com> Cc: r-help <r-help@r-project.org> Subject: Re: [R] Boxplot, formula interface, and labels. mybp <- boxplot(count ~ geno * tissue, data = mydata, plot = FALSE) mybp$names <- gsub("\\.", "\n", mybp$names) bxp(mybp) See ?boxplot for details. Best, Ista On Thu, Sep 28, 2017 at 12:40 PM, Ed Siefker <ebs15...@gmail.com> wrote: > I have data I'd like to plot using the formula interface to boxplot. > I call boxplot like so: > > with(mydata, boxplot(count ~ geno * tissue)) > > I get a boxplot with x axis labels like "wt.kidney". I would like to > change the '.' to a newline. Where is this separator configured? > > Thanks, > -Ed > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot, formula interface, and labels.
mybp <- boxplot(count ~ geno * tissue, data = mydata, plot = FALSE) mybp$names <- gsub("\\.", "\n", mybp$names) bxp(mybp) See ?boxplot for details. Best, Ista On Thu, Sep 28, 2017 at 12:40 PM, Ed Siefkerwrote: > I have data I'd like to plot using the formula interface to boxplot. > I call boxplot like so: > > with(mydata, boxplot(count ~ geno * tissue)) > > I get a boxplot with x axis labels like "wt.kidney". I would like > to change the '.' to a newline. Where is this separator configured? > > Thanks, > -Ed > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot, formula interface, and labels.
Another way to think of this problem. If I could get my hands on the vector of names boxplot() is creating, I could use gsub() to replace '.' with '\n'. Is there something I could run before boxplot() that would give me that vector of names which I could then pass to boxplot()? On Thu, Sep 28, 2017 at 11:40 AM, Ed Siefkerwrote: > I have data I'd like to plot using the formula interface to boxplot. > I call boxplot like so: > > with(mydata, boxplot(count ~ geno * tissue)) > > I get a boxplot with x axis labels like "wt.kidney". I would like > to change the '.' to a newline. Where is this separator configured? > > Thanks, > -Ed __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot, formula interface, and labels.
I have data I'd like to plot using the formula interface to boxplot. I call boxplot like so: with(mydata, boxplot(count ~ geno * tissue)) I get a boxplot with x axis labels like "wt.kidney". I would like to change the '.' to a newline. Where is this separator configured? Thanks, -Ed __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot: Plot outliners in a different window
Hi, I want to draw a usual boxplot. I have one outliner way up. It makes my boxes being drawn tiny. I do not want to delete the outliner as it is also of ecological importance. I know there is a way of drawing a second window on top of the boxplot which starts at a different y-axis-scales and includes the outliners there. I saw it on a poster once. I can't find the command though. Does anyone know it? Best regards, Tagmarie -- View this message in context: http://r.789695.n4.nabble.com/Boxplot-Plot-outliners-in-a-different-window-tp4712869.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot: Plot outliners in a different window
Hi Tagmarie, Have a look at gap.boxplot (plotrix). JIim On Mon, Sep 28, 2015 at 4:50 PM, Tagmariewrote: > Hi, > I want to draw a usual boxplot. I have one outliner way up. It makes my > boxes being drawn tiny. I do not want to delete the outliner as it is also > of ecological importance. > I know there is a way of drawing a second window on top of the boxplot > which > starts at a different y-axis-scales and includes the outliners there. I saw > it on a poster once. I can't find the command though. Does anyone know it? > Best regards, > Tagmarie > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Boxplot-Plot-outliners-in-a-different-window-tp4712869.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] boxplot overlap beeswarm
Hi everybody, I'm new and i need help very fast. I will make a transparent boxplot overlap a beeswarm. I don't want to use ggplot2, i will use ggplot. Here is my own script but it doesn't worked. Maybe you can help me. Thanks in advance Julia require(beeswarm)#rohdaten boxplots rm(list=ls()) setwd("C:/Dokumente und Einstellungen/jbellsta/Desktop/Paper") #read data data = read.csv(file="HypocotylCellLength.csv",stringsAsFactors=FALSE,header=TRUE, as.is=TRUE, sep=",") str(data) attach(data) #schreibe gröÃten wert in Variable L.max L.max <- max(LengthMM) boxplot(LengthMM ~ Label, boxwex=.3, outline=F, add=T, ylim=c(0, L.max)) beeswarm(LengthMM ~ Label, # Datenpunkte LengthMM~Label pch = 20, cex= .6, spacing = .3, method =c("swarm"), col= c('grey') ) -- View this message in context: http://r.789695.n4.nabble.com/boxplot-overlap-beeswarm-tp4712727.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] boxplot overlap beeswarm
I see that you have used add = TRUE in the boxplot call. Add only makes sense if there is already a plot to which to add the boxplot. But your boxplot is first, so there isn't anything to add it to. Try doing the beeswarm plot first? Will the two plots will have the same y axis ranges? Minor notes: you don't need both as.is and stringsAsFactors in read.csv read.csv by definition uses sep=','; you do not need to specify it. If you want better help do the following: supply example data (use the "dput" function) saying it doesn't work is not enough -- describe how it did not work, and include error messages, if any read the Posting Guide (link at the bottom of every email on R-help) -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 9/24/15, 12:27 AM, "R-help on behalf of Julia89"wrote: >Hi everybody, >I'm new and i need help very fast. >I will make a transparent boxplot overlap a beeswarm. >I don't want to use ggplot2, i will use ggplot. >Here is my own script but it doesn't worked. >Maybe you can help me. >Thanks in advance >Julia > >require(beeswarm)#rohdaten boxplots > >rm(list=ls()) >setwd("C:/Dokumente und Einstellungen/jbellsta/Desktop/Paper") > >#read data >data = >read.csv(file="HypocotylCellLength.csv",stringsAsFactors=FALSE,header=TRUE >, >as.is=TRUE, sep=",") >str(data) >attach(data) > > >#schreibe gröÃten wert in Variable L.max >L.max <- max(LengthMM) > >boxplot(LengthMM ~ Label, >boxwex=.3, >outline=F, >add=T, >ylim=c(0, L.max)) > >beeswarm(LengthMM ~ Label, # Datenpunkte LengthMM~Label >pch = 20, >cex= .6, >spacing = .3, >method =c("swarm"), >col= c('grey') >) > > > > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/boxplot-overlap-beeswarm-tp4712727.html >Sent from the R help mailing list archive at Nabble.com. > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot using a shapefile
Boris Steipe boris.steipe at utoronto.ca writes: Your workflow in principle is: - read the image into an object for which you can obtain values-per-pixel in a 2D structure; - read the shapefile and convert into a polygon; - determine the bounding box of the polygon; - use the inout() function of the splancs package to get a list of booleans for the points in the bounding box, TRUE if they are _inside_ the polygon; - subset your image points to those for which inout() returns TRUE; - plot as boxplot(). The CRAN taskview http://cran.r-project.org/web/views/MedicalImaging.html has a section on general image processing, guiding you to helpful packages. Actually, this is the wrong taskview if the data are as described, as Spatial data are covered in the Spatial task view at: http://cran.r-project.org/web/views/Spatial.html The workflow as described is also muddled: [T]he shapefile takes the pixel values from the image and shows the distribution of pixels in the form of a boxplot doesn't actually mean anything without further assumptions. A shapefile is an ESRI file format for GIS vector geometries (and attributes) that may be polygons, lines or points, and has an associated coordinate reference system; it is almost never used for other kinds of data. The image - presumably a GIS raster data file, should have the same coordinate reference system, or be transformed to the same system (use spTransform in the rgdal package, which is also the package you should use for reading the input data as it correctly reads input coordinate reference systems if available). The operation then needed is called an over() method in the sp package, and extract() in the raster package. If the shapefile contains points, the over query is asking the value(s) of the raster cells (pixels) at those points, given the same coordinate reference systems - but only one boxplot. If lines, for each line you may get a vector of values from raster cells intersected by the lines, and could make a boxplot for each line; you may wish to weight each value by the length of line in each cell. If polygons, as lines, with weighting by intersection area. The over vignette in the sp package is where you need to go to begin: http://cran.r-project.org/web/packages/sp/vignettes/over.pdf and the introduction to the raster package as a further reference: http://cran.r-project.org/web/packages/raster/vignettes/Raster.pdf Ask again if you get stuck - but(!): - see here for some hints on how to ask questions productively: http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example - ... and please read the posting guide and don't post in HTML. Definitely! And note that this is a question that is better suited to the R-sig-geo list. Hope this clarifies, Roger B. On Jun 15, 2015, at 7:19 AM, Preethi Balaji preet.balaji20 at gmail.com wrote: Dear all, I am trying to generate boxplots by giving a shapefile and an image as input. The shapefile takes the pixel values from the image and shows the distribution of pixels in the form of a boxplot. Can somebody please tell me how I can execute this in R? Many thanks! -- Regards, Preethi Malur Balaji | PhD Student University College Cork | Cork, Ireland. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot using a shapefile
Dear all, Thanks very much for your help! I will keep your suggestions in mind and will get back to you if I get stuck! On Tue, Jun 16, 2015 at 1:28 PM, Roger Bivand roger.biv...@nhh.no wrote: Boris Steipe boris.steipe at utoronto.ca writes: Your workflow in principle is: - read the image into an object for which you can obtain values-per-pixel in a 2D structure; - read the shapefile and convert into a polygon; - determine the bounding box of the polygon; - use the inout() function of the splancs package to get a list of booleans for the points in the bounding box, TRUE if they are _inside_ the polygon; - subset your image points to those for which inout() returns TRUE; - plot as boxplot(). The CRAN taskview http://cran.r-project.org/web/views/MedicalImaging.html has a section on general image processing, guiding you to helpful packages. Actually, this is the wrong taskview if the data are as described, as Spatial data are covered in the Spatial task view at: http://cran.r-project.org/web/views/Spatial.html The workflow as described is also muddled: [T]he shapefile takes the pixel values from the image and shows the distribution of pixels in the form of a boxplot doesn't actually mean anything without further assumptions. A shapefile is an ESRI file format for GIS vector geometries (and attributes) that may be polygons, lines or points, and has an associated coordinate reference system; it is almost never used for other kinds of data. The image - presumably a GIS raster data file, should have the same coordinate reference system, or be transformed to the same system (use spTransform in the rgdal package, which is also the package you should use for reading the input data as it correctly reads input coordinate reference systems if available). The operation then needed is called an over() method in the sp package, and extract() in the raster package. If the shapefile contains points, the over query is asking the value(s) of the raster cells (pixels) at those points, given the same coordinate reference systems - but only one boxplot. If lines, for each line you may get a vector of values from raster cells intersected by the lines, and could make a boxplot for each line; you may wish to weight each value by the length of line in each cell. If polygons, as lines, with weighting by intersection area. The over vignette in the sp package is where you need to go to begin: http://cran.r-project.org/web/packages/sp/vignettes/over.pdf and the introduction to the raster package as a further reference: http://cran.r-project.org/web/packages/raster/vignettes/Raster.pdf Ask again if you get stuck - but(!): - see here for some hints on how to ask questions productively: http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example - ... and please read the posting guide and don't post in HTML. Definitely! And note that this is a question that is better suited to the R-sig-geo list. Hope this clarifies, Roger B. On Jun 15, 2015, at 7:19 AM, Preethi Balaji preet.balaji20 at gmail.com wrote: Dear all, I am trying to generate boxplots by giving a shapefile and an image as input. The shapefile takes the pixel values from the image and shows the distribution of pixels in the form of a boxplot. Can somebody please tell me how I can execute this in R? Many thanks! -- Regards, Preethi Malur Balaji | PhD Student University College Cork | Cork, Ireland. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Regards, Preethi Malur Balaji | PhD Student University College Cork | Cork, Ireland. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot using a shapefile
Dear all, I am trying to generate boxplots by giving a shapefile and an image as input. The shapefile takes the pixel values from the image and shows the distribution of pixels in the form of a boxplot. Can somebody please tell me how I can execute this in R? Many thanks! -- Regards, Preethi Malur Balaji | PhD Student University College Cork | Cork, Ireland. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot using a shapefile
Your workflow in principle is: - read the image into an object for which you can obtain values-per-pixel in a 2D structure; - read the shapefile and convert into a polygon; - determine the bounding box of the polygon; - use the inout() function of the splancs package to get a list of booleans for the points in the bounding box, TRUE if they are _inside_ the polygon; - subset your image points to those for which inout() returns TRUE; - plot as boxplot(). The CRAN taskview http://cran.r-project.org/web/views/MedicalImaging.html has a section on general image processing, guiding you to helpful packages. Ask again if you get stuck - but(!): - see here for some hints on how to ask questions productively: http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example - ... and please read the posting guide and don't post in HTML. B. On Jun 15, 2015, at 7:19 AM, Preethi Balaji preet.balaj...@gmail.com wrote: Dear all, I am trying to generate boxplots by giving a shapefile and an image as input. The shapefile takes the pixel values from the image and shows the distribution of pixels in the form of a boxplot. Can somebody please tell me how I can execute this in R? Many thanks! -- Regards, Preethi Malur Balaji | PhD Student University College Cork | Cork, Ireland. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
Thank you all for the feedback. I was actually amazed at not only the number but quality of responses, and they were all helpful. I have got it working now, thanks again! Kind regards, Kris 2015-06-12 7:58 GMT+08:00 John Kane jrkrid...@inbox.com: Thanks Don, I suspected there was a Boxplot() out there by was too lazy to look. I still don't see how the original code would work if label only had onevalue but I must admit what Boxplot() is actually doing is still confusing me. John Kane Kingston ON Canada -Original Message- From: macque...@llnl.gov Sent: Thu, 11 Jun 2015 21:44:39 + To: kris.si...@research.uwa.edu.au, r-help@r-project.org Subject: Re: [R] Boxplot function error-help required In addition to the other answers, I would suggest that the next time you get the could not find function message, try like this: help.search('Boxplot') Among the output from that you should see graphics::boxplot Box Plots which should lead you to boxplot instead of Boxplot. You may see considerably more output from help.search(), depending on what packages you have installed. For example, when I did it, I found that the car package has a function named Boxplot. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/11/15, 4:20 AM, Kris Singh kris.si...@research.uwa.edu.au wrote: Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords protects your account. Check it out at http://mysecurelogon.com/manager -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
In addition to the other answers, I would suggest that the next time you get the could not find function message, try like this: help.search('Boxplot') Among the output from that you should see graphics::boxplot Box Plots which should lead you to boxplot instead of Boxplot. You may see considerably more output from help.search(), depending on what packages you have installed. For example, when I did it, I found that the car package has a function named Boxplot. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/11/15, 4:20 AM, Kris Singh kris.si...@research.uwa.edu.au wrote: Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
Well it might have worked for your supervisor but I don't see how. As was mentioned it is boxplot , not Boxplot and the rest of the syntax looks dodgy to say the least. Try boxplot(Acc_S$Subj ~ Acc_S$Acc) I don't see how label = will work , ?boxplot says it should be names = and as the code stands even that would be redundant. In any case here is a quick and dirty example that seems to work. dat1 - data.frame(aa = sample(letters[1:4], 20, replace = TRUE), bb = rnorm(20), cc = rnorm(20) ) boxplot(dat1$bb~ dat1$aa, names = c(alpha, beta, gamma, delta)) Have a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and http://adv-r.had.co.nz/Reproducibility.html for some suggestions on how to ask questions here. Good luck John Kane Kingston ON Canada -Original Message- From: kris.si...@research.uwa.edu.au Sent: Thu, 11 Jun 2015 19:20:46 +0800 To: r-help@r-project.org Subject: [R] Boxplot function error-help required Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
On Jun 11, 2015, at 2:19 PM, John Kane wrote: Well it might have worked for your supervisor but I don't see how. As was mentioned it is boxplot , not Boxplot and the rest of the syntax looks dodgy to say the least. There is a Boxplot function in package 'car' and it has a labels argument which would be partially matched by a label argument, since it precedes the dots in the arglist. So I would try this: library(car) Boxplot(~Acc_S$Acc, label=Acc_S$Subj) -- David. Try boxplot(Acc_S$Subj ~ Acc_S$Acc) I don't see how label = will work , ?boxplot says it should be names = and as the code stands even that would be redundant. In any case here is a quick and dirty example that seems to work. dat1 - data.frame(aa = sample(letters[1:4], 20, replace = TRUE), bb = rnorm(20), cc = rnorm(20) ) boxplot(dat1$bb~ dat1$aa, names = c(alpha, beta, gamma, delta)) Have a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and http://adv-r.had.co.nz/Reproducibility.html for some suggestions on how to ask questions here. Good luck John Kane Kingston ON Canada -Original Message- From: kris.si...@research.uwa.edu.au Sent: Thu, 11 Jun 2015 19:20:46 +0800 To: r-help@r-project.org Subject: [R] Boxplot function error-help required Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
On Jun 11, 2015, at 2:44 PM, MacQueen, Don wrote: In addition to the other answers, I would suggest that the next time you get the could not find function message, try like this: help.search('Boxplot') Spencer Graves uses RSiteSearch() as the underlying function for sos::findFn -- David. Among the output from that you should see graphics::boxplot Box Plots which should lead you to boxplot instead of Boxplot. You may see considerably more output from help.search(), depending on what packages you have installed. For example, when I did it, I found that the car package has a function named Boxplot. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/11/15, 4:20 AM, Kris Singh kris.si...@research.uwa.edu.au wrote: Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
Thanks Don, I suspected there was a Boxplot() out there by was too lazy to look. I still don't see how the original code would work if label only had onevalue but I must admit what Boxplot() is actually doing is still confusing me. John Kane Kingston ON Canada -Original Message- From: macque...@llnl.gov Sent: Thu, 11 Jun 2015 21:44:39 + To: kris.si...@research.uwa.edu.au, r-help@r-project.org Subject: Re: [R] Boxplot function error-help required In addition to the other answers, I would suggest that the next time you get the could not find function message, try like this: help.search('Boxplot') Among the output from that you should see graphics::boxplot Box Plots which should lead you to boxplot instead of Boxplot. You may see considerably more output from help.search(), depending on what packages you have installed. For example, when I did it, I found that the car package has a function named Boxplot. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/11/15, 4:20 AM, Kris Singh kris.si...@research.uwa.edu.au wrote: Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords protects your account. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Boxplot function error-help required
R is case sensitive. try boxplot not Boxplot On Thu, Jun 11, 2015 at 7:20 AM, Kris Singh kris.si...@research.uwa.edu.au wrote: Dear Sirm/Madam, Just wondering if someone could help me. I've tried running a code on R and the code includes the following: Boxplot(~Acc_S$Acc, label=Acc_S$Subj) But I receive the following error message: *Error: could not find function Boxplot* I have tried installing all the packages but keep getting teh same error message. The code runs on my supervisors R program and produces a boxplot, but doesn't on mine and am wondering if someone could assist me. Thanks in advance, Kris -- *Kris Singh* Provisional Psychologist MPsych (Clinical Neuropsychology) / PhD Candidate Sanders Building, Room 1.10 University of Western Australia 35 Stirling Highway Crawley WA 6009 Phone: (08) 6488 1418 Email: kris.si...@research.uwa.edu.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] boxplot axis font size
Hi, I wanted to have a different font for my x-axis and y-axis. How can I use the par function to specify different font sizes for x and y axis? For example: x - matrix(rnorm(2000),200,10) colnames(x) - letters[1:10] par(cex.axis=0.5) boxplot(x,cex=0.2) But this sets the font size to 0.5 for both the x and y axis? How can I make the y-axis to 1.5? 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] boxplot axis font size
On 25/05/14 23:57, Brian Smith wrote: Hi, I wanted to have a different font for my x-axis and y-axis. How can I use the par function to specify different font sizes for x and y axis? For example: x - matrix(rnorm(2000),200,10) colnames(x) - letters[1:10] par(cex.axis=0.5) boxplot(x,cex=0.2) But this sets the font size to 0.5 for both the x and y axis? How can I make the y-axis to 1.5? How about: boxplot(x,cex=0.2,axes=FALSE) axis(1,cex.axis=0.5) axis(2,cex.axis=1.5) Does that get you what you want? cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot colors
Hi Im producing boxplots based on factors and rearranging them by median (This is for a Geochemistry element). Im giving each boxplot a unique color based on its level (factor) name. Im trying to produce a look up list to produce these colors as the order of the boxplots will change from element to element. Here is by color lool up and boxplot code: colors_list-list(Dalradian Appin Group quartzite=#00,Sperrins Dalradian (position uncertain)=#D7D79E, Namurian sandstone, shale=#C7D79E,Lr-Mid Ordovocian acid volcanics=#FFD37F, Tertiary granite, felsite=#FF5500,Caledonian appinite suite=#946379, Dalradian Argyll Gp quartzite=#00,Slishwood Division =#FFEDCC, Dalradian S Highland Gp volcanics=#00E6A9,LEITRIM GP; Visean mudstone, sandstone=#E6, Dalradian Argyll Group=#FFD9C7,Metadolerite or amphibolite=#4C7300, Caledonian granite=#FF7F7F,Dalradian Appin Group=#9EAAD7, Lr-Mid Ordovician basic volcanics=#448970,Ordovician Granite=#E6, Tertiary basic intrusion=#8400A8,Dalradian Argyll Gp volcanics=#00E6A9, VISEAN \\basal clastics\\=#73A6A6,Carboniferous volcs minor intrus=#AAFF00, Metagabbro, metadiorite (Tyrone Plu=#00A885,TYRONE GP; Visean mudstone, sandstone=#CC, Late Visean-Westphalian 'ORS'=#F5A27A,Dalradian S Highland Group=#FFD9C7, Mid Devonian ORS=#FFD37F,Mid-Up Ordovician slate=#C2753D, Interbasaltic formation laterite, b=#00,Visean shelf limestone, shale=#FF00C5, Tertiary rhyolite (volcintru)=#FFEABE,COURCEYAN \\basal clastics\\=#4D8099, Up Dev-Lr Carb ORS=#CDAA66,Tyrone CI (Corvanaghan=?Slishwood=#C9FFC9, Visean basinal limestone \\Calp\\=#CFD6EB,Mid-Up Ordovician g'wacke, sndst, shale=#C29ED7, Up Silurian - Lr Devonian ORS=#CD8966,Westphalian shale, sandstone=#B2B2B2, Upper Basalt Formation=#FAC2E0,Causeway Tholeiite Mbr=#C29ED7, Courceyan limestone=#73B2FF,Tertiary minor volcanics=#E600A9, Silurian sandstone, g'wacke, shale=#ADE6D1,Up Cretaceous limestone=#73FFDF, Lower Basalt Formation=#E0A8C7,Ballycastle succession=#CCB3B3, Navan Group=#408CBF,Devonian basic volcs, minor intrus=#A5F57A, Up. Ord-Sil \\Moffat shale\\ etc.=#DB,Oligocene clay, sand=#704489, Lr Jurassic mudstone=#704489,Lr Jurassic mudstone=#267300, Mid-Up Ordovician acid volcanics=#448970,Armagh Gp=#8073B3, Rathkenny Formation=#704489,Triassic sandstone=#F7DB5E, Waulsortian Limestones=#B2B2B2,Permian sandstone=#F5CA7A, Mid-Up Ordovician basic volcanics=#448970) boxplot(na.omit(C_pH$DATA.pH)~bymedian,axes=FALSE,horizontal=TRUE,col=unlist(colors_list),outwex=one,whisklty = solid,whisklwd=lwth,outcol= black, outpch=dtsym, outcex=dtsize) However it is not reading the colors based on the color_list given here. Anyone know how to solve this? Thanks for your help -- Shane [[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] Boxplot colors
## Shane, ## This uses your color_list. Your other variables weren't included in the email ## so I invented some data. ## I recommend bwplot() using panel=panel.bwplot.superpose ## and I also show how to use boxplot() ## install.packages(HH) ## if necessary. library(HH) ## install.packages(reshape2) ## if necessary. library(reshape2) ## you didn't include data, so I am making up some data pH - data.frame(matrix(rnorm(200), 10, 20)) bwplot(value ~ variable, data=melt(pH), col=unlist(colors_list), panel=panel.bwplot.superpose, groups=variable) boxplot(value ~ variable, data=melt(pH), col=unlist(colors_list)) ## Rich On Thu, May 22, 2014 at 5:50 AM, Shane Carey careys...@gmail.com wrote: Hi Im producing boxplots based on factors and rearranging them by median (This is for a Geochemistry element). Im giving each boxplot a unique color based on its level (factor) name. Im trying to produce a look up list to produce these colors as the order of the boxplots will change from element to element. Here is by color lool up and boxplot code: colors_list-list(Dalradian Appin Group quartzite=#00,Sperrins Dalradian (position uncertain)=#D7D79E, Namurian sandstone, shale=#C7D79E,Lr-Mid Ordovocian acid volcanics=#FFD37F, Tertiary granite, felsite=#FF5500,Caledonian appinite suite=#946379, Dalradian Argyll Gp quartzite=#00,Slishwood Division =#FFEDCC, Dalradian S Highland Gp volcanics=#00E6A9,LEITRIM GP; Visean mudstone, sandstone=#E6, Dalradian Argyll Group=#FFD9C7,Metadolerite or amphibolite=#4C7300, Caledonian granite=#FF7F7F,Dalradian Appin Group=#9EAAD7, Lr-Mid Ordovician basic volcanics=#448970,Ordovician Granite=#E6, Tertiary basic intrusion=#8400A8,Dalradian Argyll Gp volcanics=#00E6A9, VISEAN \\basal clastics\\=#73A6A6,Carboniferous volcs minor intrus=#AAFF00, Metagabbro, metadiorite (Tyrone Plu=#00A885,TYRONE GP; Visean mudstone, sandstone=#CC, Late Visean-Westphalian 'ORS'=#F5A27A,Dalradian S Highland Group=#FFD9C7, Mid Devonian ORS=#FFD37F,Mid-Up Ordovician slate=#C2753D, Interbasaltic formation laterite, b=#00,Visean shelf limestone, shale=#FF00C5, Tertiary rhyolite (volcintru)=#FFEABE,COURCEYAN \\basal clastics\\=#4D8099, Up Dev-Lr Carb ORS=#CDAA66,Tyrone CI (Corvanaghan=?Slishwood=#C9FFC9, Visean basinal limestone \\Calp\\=#CFD6EB,Mid-Up Ordovician g'wacke, sndst, shale=#C29ED7, Up Silurian - Lr Devonian ORS=#CD8966,Westphalian shale, sandstone=#B2B2B2, Upper Basalt Formation=#FAC2E0,Causeway Tholeiite Mbr=#C29ED7, Courceyan limestone=#73B2FF,Tertiary minor volcanics=#E600A9, Silurian sandstone, g'wacke, shale=#ADE6D1,Up Cretaceous limestone=#73FFDF, Lower Basalt Formation=#E0A8C7,Ballycastle succession=#CCB3B3, Navan Group=#408CBF,Devonian basic volcs, minor intrus=#A5F57A, Up. Ord-Sil \\Moffat shale\\ etc.=#DB,Oligocene clay, sand=#704489, Lr Jurassic mudstone=#704489,Lr Jurassic mudstone=#267300, Mid-Up Ordovician acid volcanics=#448970,Armagh Gp=#8073B3, Rathkenny Formation=#704489,Triassic sandstone=#F7DB5E, Waulsortian Limestones=#B2B2B2,Permian sandstone=#F5CA7A, Mid-Up Ordovician basic volcanics=#448970) boxplot(na.omit(C_pH$DATA.pH)~bymedian,axes=FALSE,horizontal=TRUE,col=unlist(colors_list),outwex=one,whisklty = solid,whisklwd=lwth,outcol= black, outpch=dtsym, outcex=dtsize) However it is not reading the colors based on the color_list given here. Anyone know how to solve this? Thanks for your help -- Shane [[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] Boxplot colors
Thanks very much, that worked superb! On Thu, May 22, 2014 at 3:41 PM, Richard M. Heiberger r...@temple.eduwrote: ## Shane, ## This uses your color_list. Your other variables weren't included in the email ## so I invented some data. ## I recommend bwplot() using panel=panel.bwplot.superpose ## and I also show how to use boxplot() ## install.packages(HH) ## if necessary. library(HH) ## install.packages(reshape2) ## if necessary. library(reshape2) ## you didn't include data, so I am making up some data pH - data.frame(matrix(rnorm(200), 10, 20)) bwplot(value ~ variable, data=melt(pH), col=unlist(colors_list), panel=panel.bwplot.superpose, groups=variable) boxplot(value ~ variable, data=melt(pH), col=unlist(colors_list)) ## Rich On Thu, May 22, 2014 at 5:50 AM, Shane Carey careys...@gmail.com wrote: Hi Im producing boxplots based on factors and rearranging them by median (This is for a Geochemistry element). Im giving each boxplot a unique color based on its level (factor) name. Im trying to produce a look up list to produce these colors as the order of the boxplots will change from element to element. Here is by color lool up and boxplot code: colors_list-list(Dalradian Appin Group quartzite=#00,Sperrins Dalradian (position uncertain)=#D7D79E, Namurian sandstone, shale=#C7D79E,Lr-Mid Ordovocian acid volcanics=#FFD37F, Tertiary granite, felsite=#FF5500,Caledonian appinite suite=#946379, Dalradian Argyll Gp quartzite=#00,Slishwood Division =#FFEDCC, Dalradian S Highland Gp volcanics=#00E6A9,LEITRIM GP; Visean mudstone, sandstone=#E6, Dalradian Argyll Group=#FFD9C7,Metadolerite or amphibolite=#4C7300, Caledonian granite=#FF7F7F,Dalradian Appin Group=#9EAAD7, Lr-Mid Ordovician basic volcanics=#448970,Ordovician Granite=#E6, Tertiary basic intrusion=#8400A8,Dalradian Argyll Gp volcanics=#00E6A9, VISEAN \\basal clastics\\=#73A6A6,Carboniferous volcs minor intrus=#AAFF00, Metagabbro, metadiorite (Tyrone Plu=#00A885,TYRONE GP; Visean mudstone, sandstone=#CC, Late Visean-Westphalian 'ORS'=#F5A27A,Dalradian S Highland Group=#FFD9C7, Mid Devonian ORS=#FFD37F,Mid-Up Ordovician slate=#C2753D, Interbasaltic formation laterite, b=#00,Visean shelf limestone, shale=#FF00C5, Tertiary rhyolite (volcintru)=#FFEABE,COURCEYAN \\basal clastics\\=#4D8099, Up Dev-Lr Carb ORS=#CDAA66,Tyrone CI (Corvanaghan=?Slishwood=#C9FFC9, Visean basinal limestone \\Calp\\=#CFD6EB,Mid-Up Ordovician g'wacke, sndst, shale=#C29ED7, Up Silurian - Lr Devonian ORS=#CD8966,Westphalian shale, sandstone=#B2B2B2, Upper Basalt Formation=#FAC2E0,Causeway Tholeiite Mbr=#C29ED7, Courceyan limestone=#73B2FF,Tertiary minor volcanics=#E600A9, Silurian sandstone, g'wacke, shale=#ADE6D1,Up Cretaceous limestone=#73FFDF, Lower Basalt Formation=#E0A8C7,Ballycastle succession=#CCB3B3, Navan Group=#408CBF,Devonian basic volcs, minor intrus=#A5F57A, Up. Ord-Sil \\Moffat shale\\ etc.=#DB,Oligocene clay, sand=#704489, Lr Jurassic mudstone=#704489,Lr Jurassic mudstone=#267300, Mid-Up Ordovician acid volcanics=#448970,Armagh Gp=#8073B3, Rathkenny Formation=#704489,Triassic sandstone=#F7DB5E, Waulsortian Limestones=#B2B2B2,Permian sandstone=#F5CA7A, Mid-Up Ordovician basic volcanics=#448970) boxplot(na.omit(C_pH$DATA.pH)~bymedian,axes=FALSE,horizontal=TRUE,col=unlist(colors_list),outwex=one,whisklty = solid,whisklwd=lwth,outcol= black, outpch=dtsym, outcex=dtsize) However it is not reading the colors based on the color_list given here. Anyone know how to solve this? Thanks for your help -- Shane [[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. -- Shane [[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] boxplot with x-axis time
Something like: tmp - boxplot(V ~ date, data=pippo, plot=FALSE) bxp(tmp, at=sort(unique(pippo$date)) You may need to adjust the x-axis limits and the box widths. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 3/13/14 2:30 PM, giuseppe calamita calamita_giuse...@yahoo.it wrote: Dear R-users, I want to plot boxplots of a single variable collected a few times during almost one year and I would like the x-axis to recognize the date-class of the variable. I found some topics in the archive but: - some questions were poorly posed (http://r.789695.n4.nabble.com/Boxplot-with-dates-td896401.html) and so with no answer; - others, only address the topic of have the date on the x-axes ordered (http://r.789695.n4.nabble.com/Using-boxplot-in-a-daily-time-series-td8430 60.html#a843061); - finally, another topic (http://r.789695.n4.nabble.com/Boxplot-position-on-X-axis-relative-to-it-s -value-td2196020.html)is quite close to what I need but it is not exactly the same. I attached a simulated data.frame: it 2-column, the1-st are date and the 2-nd is the variable. Here the code I use: pippo- read.csv(pippo.csv) pippo$date- as.Date(pippo$date, format=%Y-%m-%d) boxplot(V ~ date, data=pippo) I would like that the x-axis look like in this plot plot(V ~ date, data=pippo) where the thick reproduce the right time of the year . Thank you for your help __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] boxplot with x-axis time
Dear R-users, I want to plot boxplots of a single variable collected a few times during almost one year and I would like the x-axis to recognize the date-class of the variable. I found some topics in the archive but: - some questions were poorly posed (http://r.789695.n4.nabble.com/Boxplot-with-dates-td896401.html) and so with no answer; - others, only address the topic of have the date on the x-axes ordered (http://r.789695.n4.nabble.com/Using-boxplot-in-a-daily-time-series-td843060.html#a843061); - finally, another topic (http://r.789695.n4.nabble.com/Boxplot-position-on-X-axis-relative-to-it-s-value-td2196020.html)is quite close to what I need but it is not exactly the same. I attached a simulated data.frame: it 2-column, the1-st are date and the 2-nd is the variable. Here the code I use: pippo- read.csv(pippo.csv) pippo$date- as.Date(pippo$date, format=%Y-%m-%d) boxplot(V ~ date, data=pippo) I would like that the x-axis look like in this plot plot(V ~ date, data=pippo) where the thick reproduce the right time of the year . Thank you for your help__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] BoxPlot basic help
Hi, May be this helps: dat - read.table(text=Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43,sep=,header=TRUE,stringsAsFactors=FALSE) boxplot(Basic~Designation,data=dat,col=2:3) #or library(ggplot2) ggplot(dat,aes(x=Designation,y=Basic,fill=Designation))+geom_boxplot() A.K. Hello - I've been away from stat programming for a very long time and am just getting back into it. I'm not used to a non GUI interface which is where I'm running into problems with R. I have a data set that i'd like to use to create boxplots. the dataset sample looks as follows Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43 I have my grouping variable under 'designation' that i would like to use to create the boxplot. Could i request some help on the syntax to use after i have read this data file into a variable, say 'data' to group the information as per the grouping variable ? how do i define the grouping variable and use it in the boxplot command ? Any information would be greatly appreciated. in addition, if you could also point me to some basic training guides, that would be helpful as well. Thanks! Raol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] BoxPlot basic help
You asked for basic training guides... 1. An Introduction to R ships with R. Did you miss it? 2. Google is your friend. There are a ton on the web. Search! -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Sat, Mar 8, 2014 at 9:18 AM, arun smartpink...@yahoo.com wrote: Hi, May be this helps: dat - read.table(text=Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43,sep=,header=TRUE,stringsAsFactors=FALSE) boxplot(Basic~Designation,data=dat,col=2:3) #or library(ggplot2) ggplot(dat,aes(x=Designation,y=Basic,fill=Designation))+geom_boxplot() A.K. Hello - I've been away from stat programming for a very long time and am just getting back into it. I'm not used to a non GUI interface which is where I'm running into problems with R. I have a data set that i'd like to use to create boxplots. the dataset sample looks as follows Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43 I have my grouping variable under 'designation' that i would like to use to create the boxplot. Could i request some help on the syntax to use after i have read this data file into a variable, say 'data' to group the information as per the grouping variable ? how do i define the grouping variable and use it in the boxplot command ? Any information would be greatly appreciated. in addition, if you could also point me to some basic training guides, that would be helpful as well. Thanks! Raol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot from statistics of original data
Hi, I have a data set that contains a set of universities and a number of statistics about the performance of students on an exam. A sample of the table follows: Institutions_Name Mean Median Minimum Maximum 1Quartile 3Quartile CENTRO UNIVERSITÁRIO LUTERANO DE MANAUS 58,5 57,5 0 98 27,6% 13,8% CENTRO UNIVERSITÁRIO DO NORTE 49 47,3 15 85 36,5% 8,1% FACULDADE METROPOLITANA DE MANAUS 41,2 41 15 71,5 64,3% 0,0% UNIVERSIDADE FEDERAL DO AMAPÁ 62,6 63,5 42 80 20,0% 40,0% CENTRO DE ENSINO SUPERIOR DO AMAPÁ 56,3 57,5 26,5 87,5 7,4% 14,8% Can I build a set of bloxplots in R using only this information? I know how to build a boxplot using the boxplot function, but I do not have access to the actual data, just this statistics. Thanks, Rodrigo Cesar da Silva Analista de Informações IPPLAN - Instituto de Pesquisa Adm e Planejamento Tel.: (12) 99258-1042 [[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] Boxplot from statistics of original data
The boxplot function calls other functions, the boxplot.stats function calculates the stats, then the bxp function does the actual plotting. So just look at the structure of the object that is passed to bxp, reformat your data to that structure, and call bxp directly. On Thu, Sep 26, 2013 at 8:10 AM, Rodrigo César da Silva rodrigo.si...@ipplan.org.br wrote: Hi, I have a data set that contains a set of universities and a number of statistics about the performance of students on an exam. A sample of the table follows: Institutions_Name Mean Median Minimum Maximum 1Quartile 3Quartile CENTRO UNIVERSITÁRIO LUTERANO DE MANAUS 58,5 57,5 0 98 27,6% 13,8% CENTRO UNIVERSITÁRIO DO NORTE 49 47,3 15 85 36,5% 8,1% FACULDADE METROPOLITANA DE MANAUS 41,2 41 15 71,5 64,3% 0,0% UNIVERSIDADE FEDERAL DO AMAPÁ 62,6 63,5 42 80 20,0% 40,0% CENTRO DE ENSINO SUPERIOR DO AMAPÁ 56,3 57,5 26,5 87,5 7,4% 14,8% Can I build a set of bloxplots in R using only this information? I know how to build a boxplot using the boxplot function, but I do not have access to the actual data, just this statistics. Thanks, Rodrigo Cesar da Silva Analista de Informações IPPLAN - Instituto de Pesquisa Adm e Planejamento Tel.: (12) 99258-1042 [[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 [[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] Boxplot from statistics of original data
On 09/27/2013 12:10 AM, Rodrigo César da Silva wrote: Hi, I have a data set that contains a set of universities and a number of statistics about the performance of students on an exam. A sample of the table follows: Institutions_Name Mean Median Minimum Maximum 1Quartile 3Quartile CENTRO UNIVERSITÁRIO LUTERANO DE MANAUS 58,5 57,5 0 98 27,6% 13,8% ... Hi Rodrigo, I was about to answer this post last night when I noticed that you seem to have different measures for the last two values in each set. Unless I am sadly mistaken, the first and third quartile should bracket the median. I would check what these two figures mean before trying to build a boxplot. 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] boxplot with grouped variables
my dataset looked like this in the beginning: Daten V1 V2 V3 1 Dosis Gewicht Geschlecht 2 06.62 m 3 06.65 m 4 05.78 m 5 05.63 m I need box plots for V2 with all combination of V1 and V3, so I deleted the first row, and tried this: boxplot(Daten$V2[Daten$V3==m]) but it does not work and I have no clue what I did wrong. I'm thankful for any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot with grouped variables
Hi, Try this: dat1- read.table(text= V1 V2 V3 1 Dosis Gewicht Geschlecht 2 0 6.62 m 3 0 6.65 m 4 0 5.78 m 5 0 5.63 m 6 1 6.78 m 7 1 6.45 m 8 1 5.68 m 9 1 5.89 m 10 0 6.72 f 11 0 6.75 f 12 0 5.89 f 13 0 5.78 f 14 1 6.89 f 15 1 7.75 f 16 1 4.89 f 17 1 5.89 f ,header=TRUE,sep=,stringsAsFactors=FALSE) dat2-dat1[-1,] boxplot(as.numeric(dat2$V2)[dat2$V3==m])# works dat2$V2- as.numeric(dat2$V2) library(ggplot2) library(plyr) library(reshape2) dat2New-mutate(melt(dat2,id.var=c(V1,V3)),combin= as.character(interaction(V1,V3,sep=_))) ggplot(dat2New,aes(x=combin,y=value))+geom_boxplot() #or ggplot(dat2New,aes(x=combin,y=value))+geom_boxplot()+facet_wrap(~V3,scales=free_x,ncol=2) A.K. - Original Message - From: maggy yan kiot...@gmail.com To: R-help@r-project.org Cc: Sent: Saturday, May 11, 2013 11:40 AM Subject: [R] boxplot with grouped variables my dataset looked like this in the beginning: Daten V1 V2 V3 1 Dosis Gewicht Geschlecht 2 0 6.62 m 3 0 6.65 m 4 0 5.78 m 5 0 5.63 m I need box plots for V2 with all combination of V1 and V3, so I deleted the first row, and tried this: boxplot(Daten$V2[Daten$V3==m]) but it does not work and I have no clue what I did wrong. I'm thankful for any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot with grouped variables
It will not work because the presence of the first row means that all the variables are read in as factors, not numeric. You must convert numeric variables to numeric **after** eliminating the first row, or read the data in using read.table(..., head=TRUE). See ?read.table for details. **After** the above changes, perhaps with(Daten, boxplot(Gewicht ~ interaction(Dosis,Geshlecht, drop=TRUE)) ) will work if you read in column names properly. Otherwise, V2 ~interaction(V1,V3, drop=TRUE) if you do the conversions to numeric. Please read *An Introduction to R or other online R tutorial before posting further here. You need to understand basic R data handling before you proceed. At present, you do not. -- Bert On Sat, May 11, 2013 at 8:40 AM, maggy yan kiot...@gmail.com wrote: my dataset looked like this in the beginning: Daten V1 V2 V3 1 Dosis Gewicht Geschlecht 2 06.62 m 3 06.65 m 4 05.78 m 5 05.63 m I need box plots for V2 with all combination of V1 and V3, so I deleted the first row, and tried this: boxplot(Daten$V2[Daten$V3==m]) but it does not work and I have no clue what I did wrong. I'm thankful for any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot with grouped variables
You can't mix number and character data in a data frame column, so you will probably find that all your variables are factors, not numbers. Try, for example class(Daten$V2) It looks like you failed to specify 'header=TRUE' in a read.table statement. Reread the data with headers properly treated so that those first items become the variable names. In additon, Daten$V2[Daten$V3==m]) will only give you data for rows in which V3==m, which will be a single boxplot. (see ?[ for what that subsetting operation does). To plot all combinations ( if V2 were correctly numeric) you could try boxplot(V2~V1+V3, data=Daten) S Ellison From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of maggy yan [kiot...@gmail.com] Sent: 11 May 2013 16:40 To: R-help@r-project.org Subject: [R] boxplot with grouped variables my dataset looked like this in the beginning: Daten V1 V2 V3 1 Dosis Gewicht Geschlecht 2 06.62 m 3 06.65 m 4 05.78 m 5 05.63 m I need box plots for V2 with all combination of V1 and V3, so I deleted the first row, and tried this: boxplot(Daten$V2[Daten$V3==m]) but it does not work and I have no clue what I did wrong. I'm thankful for any help! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot Labels OK
Beatriz, In this case, use the car package and run the following: bp - Boxplot(DATA$ave, data= DATA, main= Average Size, labels=DATA$num, Id.method=c(y)) This will print out the labels 211 225 beside the outlier points. As you can see, the instruction assigns the values in the num column in the DATA data frame to the labels. If you prefer the interactive option, replace id.method=c(y) with id.method=c(identify) Kind regards, José José Iparraguirre Chief Economist Age UK T 020 303 31482 E jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Tavis House, 1- 6 Tavistock Square London, WC1H 9NB www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Beatriz González Domínguez Sent: 09 April 2013 17:32 To: r-help-ow...@r-project.org; R Help 1; R Help 2 Subject: [R] Boxplot Labels OK Dear all, I have just sent an enquiry but probably I hadn’t expressed myself properly. Could anyone help me with the following? When I run the code on my data I get a boxplot with outliers identified by numbers 200 201. However, what I would like is to label these outliers with their corresponding “DATA$numâ€? values of the data frame. In this example, the outliers should be labelled as: 211 225 Do you have any idea of how I could do this? Please, if you need any more details just get in touch. Many thanks in advance! ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) Bea [[alternative HTML version deleted]] Please donate to the Syria Crisis Appeal by text or online: To donate £5 by mobile, text SYRIA to 70800. To donate online, please visit http://www.ageinternational.org.uk/syria Over one million refugees are desperately in need of water, food, healthcare, warm clothing, blankets and shelter; Age International urgently needs your support to help affected older refugees. Age International is a subsidiary charity of Age UK and a member of the Disasters Emergency Committee (DEC). The DEC launches and co-ordinates national fundraising appeals for public donations on behalf of its member agencies. Texts cost £5 plus one standard rate message. Age International will receive a minimum of £4.96. More info at ageinternational.org.uk/SyriaTerms --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot Labels solved
Hi Jose, Thanks a lot for your email! I was told a good solution to label outliers of a boxplot with identifying variable values of the data frame (instead of the row names). An example can be seen below: ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(rep(1, nrow(DATA)), DATA$ave, labels=DATA$num, cex=.7) Bea -Original Message- From: Jose Iparraguirre Sent: Wednesday, April 10, 2013 10:19 AM To: Beatriz González Domínguez ; r-help-ow...@r-project.org ; R Help 1 ; R Help 2 Subject: RE: [R] Boxplot Labels OK Beatriz, In this case, use the car package and run the following: bp - Boxplot(DATA$ave, data= DATA, main= Average Size, labels=DATA$num, Id.method=c(y)) This will print out the labels 211 225 beside the outlier points. As you can see, the instruction assigns the values in the num column in the DATA data frame to the labels. If you prefer the interactive option, replace id.method=c(y) with id.method=c(identify) Kind regards, José José Iparraguirre Chief Economist Age UK T 020 303 31482 E jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Tavis House, 1- 6 Tavistock Square London, WC1H 9NB www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Beatriz González Domínguez Sent: 09 April 2013 17:32 To: r-help-ow...@r-project.org; R Help 1; R Help 2 Subject: [R] Boxplot Labels OK Dear all, I have just sent an enquiry but probably I hadn’t expressed myself properly. Could anyone help me with the following? When I run the code on my data I get a boxplot with outliers identified by numbers 200 201. However, what I would like is to label these outliers with their corresponding “DATA$numâ€? values of the data frame. In this example, the outliers should be labelled as: 211 225 Do you have any idea of how I could do this? Please, if you need any more details just get in touch. Many thanks in advance! ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) Bea [[alternative HTML version deleted]] Please donate to the Syria Crisis Appeal by text or online: To donate £5 by mobile, text SYRIA to 70800. To donate online, please visit http://www.ageinternational.org.uk/syria Over one million refugees are desperately in need of water, food, healthcare, warm clothing, blankets and shelter; Age International urgently needs your support to help affected older refugees. Age International is a subsidiary charity of Age UK and a member of the Disasters Emergency Committee (DEC). The DEC launches and co-ordinates national fundraising appeals for public donations on behalf of its member agencies. Texts cost £5 plus one standard rate message. Age International will receive a minimum of £4.96. More info at ageinternational.org.uk/SyriaTerms --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confide...{{dropped:27}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot Labels
#Dear all, #Could anyone help me with the following? #DATA num - as.numeric(seq(100:125)) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) #I would like the labels that appear in the boxplot to be DATA$num values. #When I identify the outlier it appears a 1 when I would like to appear a 26 #Do you have any idea of how I could do that? #Many thanks! #Bea [[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] Boxplot Labels
#Dear all, #Could anyone help me with the following? #DATA num - as.numeric(seq(100:125)) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) #I would like the labels that appear in the boxplot to be DATA$num values. #When I identify the outlier it appears a 1 when I would like to appear a 26 #Do you have any idea of how I could do that? #Many thanks! #Bea [[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] Boxplot Labels
Estimada Beatriz, If you use the Box.plot function in the car package (notice that here it's Box.plot, not box.plot), and add the argument id.method=c(identify), it should work. You only need one instruction: R library(car) R bp - Boxplot(DATA$ave, data= DATA, main= Average Size,id.method=c(identify)) Kind regards, José José Iparraguirre Chief Economist Age UK T 020 303 31482 E jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Tavis House, 1- 6 Tavistock Square London, WC1H 9NB www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Beatriz González Domínguez Sent: 09 April 2013 16:17 To: R Help; r-help@r-project.org Subject: [R] Boxplot Labels #Dear all, #Could anyone help me with the following? #DATA num - as.numeric(seq(100:125)) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) #I would like the labels that appear in the boxplot to be DATA$num values. #When I identify the outlier it appears a 1 when I would like to appear a 26 #Do you have any idea of how I could do that? #Many thanks! #Bea [[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. Please donate to the Syria Crisis Appeal by text or online: To donate £5 by mobile, text SYRIA to 70800. To donate online, please visit http://www.ageinternational.org.uk/syria Over one million refugees are desperately in need of water, food, healthcare, warm clothing, blankets and shelter; Age International urgently needs your support to help affected older refugees. Age International is a subsidiary charity of Age UK and a member of the Disasters Emergency Committee (DEC). The DEC launches and co-ordinates national fundraising appeals for public donations on behalf of its member agencies. Texts cost £5 plus one standard rate message. Age International will receive a minimum of £4.96. More info at ageinternational.org.uk/SyriaTerms --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot Labels
p - boxplot(dat1$ave, data= dat1, main= Average Size, yaxt = n) text(1.1, , y = max(dat1$ave), label = 26, cex = .7) but I don't understand #I would like the labels that appear in the boxplot to be DATA$num values. You want 26 values potted? John Kane Kingston ON Canada -Original Message- From: aguitatie...@hotmail.com Sent: Tue, 9 Apr 2013 16:17:01 +0100 To: r-help-boun...@r-project.org, r-help@r-project.org Subject: [R] Boxplot Labels #Dear all, #Could anyone help me with the following? #DATA num - as.numeric(seq(100:125)) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) #I would like the labels that appear in the boxplot to be DATA$num values. #When I identify the outlier it appears a 1 when I would like to appear a 26 #Do you have any idea of how I could do that? #Many thanks! #Bea [[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. 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.
[R] Boxplot Labels OK
Dear all, I have just sent an enquiry but probably I hadnât expressed myself properly. Could anyone help me with the following? When I run the code on my data I get a boxplot with outliers identified by numbers 200 201. However, what I would like is to label these outliers with their corresponding âDATA$numâ values of the data frame. In this example, the outliers should be labelled as: 211 225 Do you have any idea of how I could do this? Please, if you need any more details just get in touch. Many thanks in advance! ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) Bea [[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] Boxplot Labels
Hello, The construct data.frame(cbind(...)) is not at all needed, the following is much better. dat1 - data.frame(num, ave) Also, I've modified the text() call a bit, in order to have R tell the dat1$num corresponding to the (unique) max of ave, and with an extra argument, pos. This would allow for placement of the label near the point. p - boxplot(dat1$ave, data= dat1, main= Average Size, yaxt = n) text(1, , y = max(dat1$ave), label = dat1$num[which.max(dat1$ave)], cex = .7, pos = 4) Hope this helps, Rui Barradas Em 09-04-2013 16:44, John Kane escreveu: p - boxplot(dat1$ave, data= dat1, main= Average Size, yaxt = n) text(1.1, , y = max(dat1$ave), label = 26, cex = .7) but I don't understand #I would like the labels that appear in the boxplot to be DATA$num values. You want 26 values potted? John Kane Kingston ON Canada -Original Message- From: aguitatie...@hotmail.com Sent: Tue, 9 Apr 2013 16:17:01 +0100 To: r-help-boun...@r-project.org, r-help@r-project.org Subject: [R] Boxplot Labels #Dear all, #Could anyone help me with the following? #DATA num - as.numeric(seq(100:125)) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) #I would like the labels that appear in the boxplot to be DATA$num values. #When I identify the outlier it appears a 1 when I would like to appear a 26 #Do you have any idea of how I could do that? #Many thanks! #Bea [[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. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot Labels
The problem is that identify() is designed for a scatterplot not a boxplot. You can use it but you have to feed it the correct x and y coordinates: identify(rep(1, nrow(DATA)), DATA$ave, cex=.7) This will give you 26 as you requested if you click on the outlying point. That is the row name for the point. You specified DATA$num as your labels, but they are the same as the row names so there is no need to add that. You can also identify points at the whiskers, hinges, or median, but they will probably overprint the lines. I wasn't sure if your definition of num was intentional or a mistype, eg: num - as.numeric(seq(100:125)) num [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 num - as.numeric(seq(100, 125)) num [1] 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 [20] 119 120 121 122 123 124 125 If you wanted the numbers from 1 to 26, num - 1:26 would be more compact. -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of John Kane Sent: Tuesday, April 09, 2013 10:45 AM To: Beatriz González Domínguez; R Help; r-help@r-project.org Subject: Re: [R] Boxplot Labels p - boxplot(dat1$ave, data= dat1, main= Average Size, yaxt = n) text(1.1, , y = max(datDAT1$ave), label = 26, cex = .7) but I don't understand #I would like the labels that appear in the boxplot to be DATA$num values. You want 26 values potted? John Kane Kingston ON Canada -Original Message- From: aguitatie...@hotmail.com Sent: Tue, 9 Apr 2013 16:17:01 +0100 To: r-help-boun...@r-project.org, r-help@r-project.org Subject: [R] Boxplot Labels #Dear all, #Could anyone help me with the following? #DATA num - as.numeric(seq(100:125)) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 3.5, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) #I would like the labels that appear in the boxplot to be DATA$num values. #When I identify the outlier it appears a 1 when I would like to appear a 26 #Do you have any idea of how I could do that? #Many thanks! #Bea [[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. 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot Labels OK
Hello, The answers you had in another thread could lead you to bp - boxplot(DATA$ave, data= DATA, main= Average Size) idx - which(DATA$ave %in% bp$out) text(x= bp$group, y= bp$out, labels= DATA$num[idx], cex = 0.7, pos = 4) Hope this helps, Rui Barradas Em 09-04-2013 17:31, Beatriz González Domínguez escreveu: Dear all, I have just sent an enquiry but probably I hadn’t expressed myself properly. Could anyone help me with the following? When I run the code on my data I get a boxplot with outliers identified by numbers 200 201. However, what I would like is to label these outliers with their corresponding “DATA$numâ€� values of the data frame. In this example, the outliers should be labelled as: 211 225 Do you have any idea of how I could do this? Please, if you need any more details just get in touch. Many thanks in advance! ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) Bea [[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] Boxplot Labels OK
Hello, I'm glad it help. You should cc the list, maybe it will be of use to others. Rui Barradas Em 09-04-2013 21:00, Beatriz González Domínguez escreveu: I have solved it, many thanks! -Original Message- From: Rui Barradas Sent: Tuesday, April 09, 2013 7:33 PM To: Beatriz González Domínguez Cc: r-help-ow...@r-project.org ; R Help 1 ; R Help 2 Subject: Re: [R] Boxplot Labels OK Hello, The answers you had in another thread could lead you to bp - boxplot(DATA$ave, data= DATA, main= Average Size) idx - which(DATA$ave %in% bp$out) text(x= bp$group, y= bp$out, labels= DATA$num[idx], cex = 0.7, pos = 4) Hope this helps, Rui Barradas Em 09-04-2013 17:31, Beatriz González Domínguez escreveu: Dear all, I have just sent an enquiry but probably I hadn’t expressed myself properly. Could anyone help me with the following? When I run the code on my data I get a boxplot with outliers identified by numbers 200 201. However, what I would like is to label these outliers with their corresponding “DATA$numâ€� values of the data frame. In this example, the outliers should be labelled as: 211 225 Do you have any idea of how I could do this? Please, if you need any more details just get in touch. Many thanks in advance! ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3, 3.2, 3.3, 7.2, 4, 4.8, 3.5, 2.7, 3.1, 2.8, 4.1, 2.0, 2.5, 2.1, 3.4, 2.5, 2.6, 7) DATA - data.frame(cbind(num, ave)) rm(num, ave) #BOXPLOT x11() bp - boxplot(DATA$ave, data= DATA, main= Average Size) identify(x= bp$group, y= bp$out, labels= DATA$num, cex = 0.7) Bea [[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] boxplot
Unless you have a really large number of wells I'd just use the brute force approach of reading in each data set with a simple read.table or read.csv like well1 - read.csv(well1.csv) type of statement and repeat for each well. Here is a simple example that may give you an idea of how to do the boxplots . I have done them two ways, one using base graphics and the other using ggplot2. You will probably have to install the ggplot2 package -- just issue the command install.packages(ggplot2) The base approach is initially a lot simpler but in the longer term, if you expect to do a lot of graphing work in R, the grid packages like ggplot2 or lattice seem to offer a lot more control for less actual typing, especially if you need publication/report quality graphics. ##===start code= set.seed(345) #reproducable sample # create three sample data sets, well_1 - data.frame(arsenic = rnorm(12)) well_2 - data.frame (arsenic = rnorm(10)) well_3 - data.frame (arsenic = rnorm(15)) wells - rbind(well_1, well_2, well_3) # create single data.frame #create an id value for each well well_id - c(rep(1,nrow(well_1)), rep(2, nrow(well_2)), rep(3, nrow(well_3))) #add the well identifier wells - cbind(wells , well_id) str(wells) # check to see what we have boxplot(arsenic ~ well_id, data = wells) # plot vertical boxplot boxplot(arsenic ~ well_id, data = wells, horizontal = TRUE,col=c(red,green,blue)) #horizontal box plot # vertical boxplot using ggplot2 library(ggplot2) p - ggplot(wells, aes(as.factor(well_id), arsenic)) + geom_boxplot() p # horizontal boxplot p1 - p + coord_flip() p1 p2 - ggplot(wells, aes(as.factor(well_id), arsenic, fill = as.factor(well_id) )) + geom_boxplot() + coord_flip() + scale_fill_discrete(guide=FALSE) ##===end code== John Kane Kingston ON Canada -Original Message- From: annij...@gmail.com Sent: Sat, 23 Mar 2013 10:22:02 -0400 To: jrkrid...@inbox.com Subject: Re: [R] boxplot Hello John, I apologize for the delayed response. Yes I am referring to the same type of data in the data sets. For example, the arsenic concentrations in individual groundwater monitoring wells at a groundwater contaminated site, where one well may have 12 concentration measurements, another well has 10, etc. Thanks Janh On Fri, Mar 22, 2013 at 5:31 PM, John Kane [1]jrkrid...@inbox.com wrote: Hi Janh, When you say that you have multiple data sets of unequal sample sizes are you speaking of the same kind of data For example are you speaking of data from a set of experiments where the variables measured are all the same and where when you graph them you expect the same x and y scales? Or are you talking about essentilly independent data sets that it makes sense to graph in a grid ? John Kane Kingston ON Canada -Original Message- From: [2]annij...@gmail.com Sent: Fri, 22 Mar 2013 10:46:21 -0400 To: [3]dcarl...@tamu.edu Subject: Re: [R] boxplot Hello All, On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert. Thanks Janh On Thu, Mar 21, 2013 at 9:19 AM, David L Carlson [4]dcarl...@tamu.edu wrote: Your variable loc_type combines information from two variables (loc and type). Since you are subsetting on loc, why not just plot by type? boxplot(var1~type, data[data$loc==nice,]) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: [5]r-help-boun...@r-project.org [mailto:[6]r-help-bounces@r- [7]project.org] On Behalf Of Jim Lemon Sent: Thursday, March 21, 2013 4:05 AM To: carol white Cc: [8]r-h...@stat.math.ethz.ch Subject: Re: [R] boxplot On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin
Re: [R] boxplot
Hello John, Thank you so much for your kind assistance and the detailed descriptions. I will play with the scripts and see which one is the easiest that serves the purpose.. Best regards, Janh On Sun, Mar 24, 2013 at 7:50 AM, John Kane jrkrid...@inbox.com wrote: ** Unless you have a really large number of wells I'd just use the brute force approach of reading in each data set with a simple read.table or read.csv like well1 - read.csv(well1.csv) type of statement and repeat for each well. Here is a simple example that may give you an idea of how to do the boxplots . I have done them two ways, one using base graphics and the other using ggplot2. You will probably have to install the ggplot2 package -- just issue the command install.packages(ggplot2) The base approach is initially a lot simpler but in the longer term, if you expect to do a lot of graphing work in R, the grid packages like ggplot2 or lattice seem to offer a lot more control for less actual typing, especially if you need publication/report quality graphics. ##===start code= set.seed(345) #reproducable sample # create three sample data sets, well_1 - data.frame(arsenic = rnorm(12)) well_2 - data.frame (arsenic = rnorm(10)) well_3 - data.frame (arsenic = rnorm(15)) wells - rbind(well_1, well_2, well_3) # create single data.frame #create an id value for each well well_id - c(rep(1,nrow(well_1)), rep(2, nrow(well_2)), rep(3, nrow(well_3))) #add the well identifier wells - cbind(wells , well_id) str(wells) # check to see what we have boxplot(arsenic ~ well_id, data = wells) # plot vertical boxplot boxplot(arsenic ~ well_id, data = wells, horizontal = TRUE,col=c(red,green,blue)) #horizontal box plot # vertical boxplot using ggplot2 library(ggplot2) p - ggplot(wells, aes(as.factor(well_id), arsenic)) + geom_boxplot() p # horizontal boxplot p1 - p + coord_flip() p1 p2 - ggplot(wells, aes(as.factor(well_id), arsenic, fill = as.factor(well_id) )) + geom_boxplot() + coord_flip() + scale_fill_discrete(guide=FALSE) ##===end code== John Kane Kingston ON Canada -Original Message- *From:* annij...@gmail.com *Sent:* Sat, 23 Mar 2013 10:22:02 -0400 *To:* jrkrid...@inbox.com *Subject:* Re: [R] boxplot Hello John, I apologize for the delayed response. Yes I am referring to the same type of data in the data sets. For example, the arsenic concentrations in individual groundwater monitoring wells at a groundwater contaminated site, where one well may have 12 concentration measurements, another well has 10, etc. Thanks Janh On Fri, Mar 22, 2013 at 5:31 PM, John Kane jrkrid...@inbox.com wrote: Hi Janh, When you say that you have multiple data sets of unequal sample sizes are you speaking of the same kind of data For example are you speaking of data from a set of experiments where the variables measured are all the same and where when you graph them you expect the same x and y scales? Or are you talking about essentilly independent data sets that it makes sense to graph in a grid ? John Kane Kingston ON Canada -Original Message- From: annij...@gmail.com Sent: Fri, 22 Mar 2013 10:46:21 -0400 To: dcarl...@tamu.edu Subject: Re: [R] boxplot Hello All, On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert. Thanks Janh On Thu, Mar 21, 2013 at 9:19 AM, David L Carlson dcarl...@tamu.edu wrote: Your variable loc_type combines information from two variables (loc and type). Since you are subsetting on loc, why not just plot by type? boxplot(var1~type, data[data$loc==nice,]) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jim Lemon Sent: Thursday, March 21, 2013 4:05 AM To: carol white Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] boxplot On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin' up on you
Re: [R] boxplot
Hello John, I apologize for the delayed response. Yes I am referring to the same type of data in the data sets. For example, the arsenic concentrations in individual groundwater monitoring wells at a groundwater contaminated site, where one well may have 12 concentration measurements, another well has 10, etc. Thanks Janh On Fri, Mar 22, 2013 at 5:31 PM, John Kane jrkrid...@inbox.com wrote: Hi Janh, When you say that you have multiple data sets of unequal sample sizes are you speaking of the same kind of data For example are you speaking of data from a set of experiments where the variables measured are all the same and where when you graph them you expect the same x and y scales? Or are you talking about essentilly independent data sets that it makes sense to graph in a grid ? John Kane Kingston ON Canada -Original Message- From: annij...@gmail.com Sent: Fri, 22 Mar 2013 10:46:21 -0400 To: dcarl...@tamu.edu Subject: Re: [R] boxplot Hello All, On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert. Thanks Janh On Thu, Mar 21, 2013 at 9:19 AM, David L Carlson dcarl...@tamu.edu wrote: Your variable loc_type combines information from two variables (loc and type). Since you are subsetting on loc, why not just plot by type? boxplot(var1~type, data[data$loc==nice,]) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jim Lemon Sent: Thursday, March 21, 2013 4:05 AM To: carol white Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] boxplot On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin' up on you. Try this: boxplot(data$var1[data$loc == nice]~ as.character(data$loc_type[data$loc == nice])) 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! Check it out at http://www.inbox.com/earth [[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] boxplot
Hello All, On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert. Thanks Janh On Thu, Mar 21, 2013 at 9:19 AM, David L Carlson dcarl...@tamu.edu wrote: Your variable loc_type combines information from two variables (loc and type). Since you are subsetting on loc, why not just plot by type? boxplot(var1~type, data[data$loc==nice,]) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jim Lemon Sent: Thursday, March 21, 2013 4:05 AM To: carol white Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] boxplot On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin' up on you. Try this: boxplot(data$var1[data$loc == nice]~ as.character(data$loc_type[data$loc == nice])) 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot
Hi Janh, When you say that you have multiple data sets of unequal sample sizes are you speaking of the same kind of data For example are you speaking of data from a set of experiments where the variables measured are all the same and where when you graph them you expect the same x and y scales? Or are you talking about essentilly independent data sets that it makes sense to graph in a grid ? John Kane Kingston ON Canada -Original Message- From: annij...@gmail.com Sent: Fri, 22 Mar 2013 10:46:21 -0400 To: dcarl...@tamu.edu Subject: Re: [R] boxplot Hello All, On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert. Thanks Janh On Thu, Mar 21, 2013 at 9:19 AM, David L Carlson dcarl...@tamu.edu wrote: Your variable loc_type combines information from two variables (loc and type). Since you are subsetting on loc, why not just plot by type? boxplot(var1~type, data[data$loc==nice,]) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jim Lemon Sent: Thursday, March 21, 2013 4:05 AM To: carol white Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] boxplot On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin' up on you. Try this: boxplot(data$var1[data$loc == nice]~ as.character(data$loc_type[data$loc == nice])) 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot
On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert. Thanks Janh Not sure without a reproducible example (please read posting guide) but maybe this will help: a = sample(1:100, 30) b = sample(1:100, 50) c = sample(50:100,19) d = sample(1:50, 15) e = sample(1:50, 15) f = sample(1:50, 25) x11(width = 7, height = 3.5) op =par(mfrow = c(1,2)) # plot side by side # horizontal boxplot(list(a,b,c), horizontal = TRUE, main = 'Horizontal', xlim = c(0,9), names = c('a', 'b','c')) boxplot(list(e, f), horizontal = TRUE, xlim = c(0,9), names = c('e', 'f'), at = c(7,8), add = TRUE, col ='red') # vertical boxplot(list(a,b,c), horizontal = FALSE, xlim = c(0,9), main = 'Verticalal', names = c('a', 'b','c')) boxplot(list(e, f), horizontal = FALSE, xlim = c(0,9), names = c('e', 'f'), at = c(7,8), add = TRUE, col ='red') par(op) Cheers, Rob ___ Robert W. Baer, Ph.D. Professor of Physiology Kirksille College of Osteopathic Medicine A. T. Still University of Health Sciences Kirksville, MO 63501 USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] boxplot
Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Thanks Carol loc typeloc_typevar1var2 niceSA nice_SA 2.96E+033.33E+03 niceSA nice_SA 4.07E+034.44E+03 niceSA nice_SA 3.33E+034.81E+03 niceAm nice_Am 3.70E+020.00E+00 niceAm nice_Am 7.41E+020.00E+00 niceAm nice_Am 1.48E+030.00E+00 niceAp nice_Ap 3.70E+020.00E+00 niceAp nice_Ap 3.70E+020.00E+00 niceAp nice_Ap 3.70E+020.00E+00 niceAm_Ap nice_Am_Ap 0.00E+000.00E+00 niceAm_Ap nice_Am_Ap 0.00E+000.00E+00 niceAm_Ap nice_Am_Ap 0.00E+000.00E+00 miceSA mice_SA 9.26E+056.67E+04 miceSA mice_SA 8.52E+057.78E+04 miceSA mice_SA 9.63E+058.15E+04 miceAm mice_Am 5.93E+035.56E+03 miceAm mice_Am 5.56E+037.04E+03 miceAm mice_Am 7.78E+037.41E+03 miceAp mice_Ap 8.89E+034.07E+03 miceAp mice_Ap 9.63E+033.33E+03 miceAp mice_Ap 1.07E+042.59E+03 miceAm_Ap mice_Am_Ap 4.07E+031.11E+03 miceAm_Ap mice_Am_Ap 4.81E+031.11E+03 miceAm_Ap mice_Am_Ap 5.56E+033.70E+02 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot
On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin' up on you. Try this: boxplot(data$var1[data$loc == nice]~ as.character(data$loc_type[data$loc == nice])) 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] boxplot
Your variable loc_type combines information from two variables (loc and type). Since you are subsetting on loc, why not just plot by type? boxplot(var1~type, data[data$loc==nice,]) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Jim Lemon Sent: Thursday, March 21, 2013 4:05 AM To: carol white Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] boxplot On 03/21/2013 07:40 PM, carol white wrote: Hi, It must be an easy question but how to boxplot a subset of data: data = read.table(my_data.txt, header = T) boxplot(data$var1[data$loc == nice]~data$loc_type[data$loc == nice]) #in this case, i want to display only the boxplot loc == nice #doesn't display the boxplot of only loc == nice. It also displays loc == mice Hi Carol, It's them old factors sneakin' up on you. Try this: boxplot(data$var1[data$loc == nice]~ as.character(data$loc_type[data$loc == nice])) 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot
Hi, I try to boxplot following data on the subset of (V1,V3,V5,V7) and (V2,V4,V6,V8) V1 V2 V3 V4 V5 V6 V7 V8 24 6 712 33 43 53 how can I use boxplot function to plot it? thanks, William __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot
v - c(V1=2, V2=4 ,V3=6 ,V4=7 ,V5=12 ,V6=33 ,V7=43 ,V8=53) boxplot(v[seq(from=1, to=8, by=2)], v[seq(from=2, to=8, by=2)]) Sincerely Marc Le 13/03/13 23:14, wei wu a écrit : Hi, I try to boxplot following data on the subset of (V1,V3,V5,V7) and (V2,V4,V6,V8) V1 V2 V3 V4 V5 V6 V7 V8 24 6 712 33 43 53 how can I use boxplot function to plot it? thanks, William __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot with frequencies(counts)
On 03/06/2013 12:45 AM, km wrote: Dear All, I have a table as following position type count 1 2 100 1 3 51 1 5 64 1 8 81 1 6 32 2 2 41 2 3 85 and so on Normally if would have a vector of 2,3,4,5... by position position and plot them by position. But now i have counts of these types. Is there a way to compute boxplot of such kind of data ? Hi KM, We must assume that the type variable is to be used as a value, otherwise you would want something like a frequency plot by two factors of position and type. (If this is the case, I would suggest a nested bar plot). Here is a fairly awful kludge that will get you a boxplot (tdf is your table): reprow-function(x) return(matrix(rep(x[1:2],x[3]),ncol=2,byrow=TRUE)) replist-apply(as.matrix(tdf),1,reprow) repmat-replist[[1]] for(rep in 1:length(replist)) repmat-rbind(repmat,replist[[rep]]) boxplot(repmat[,2],repmat[,1]) With apologies 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] boxplot with frequencies(counts)
Dear All, I have a table as following position type count 1 2 100 1 3 51 1 5 64 1 8 81 1 6 32 2 2 41 2 3 85 and so on Normally if would have a vector of 2,3,4,5... by position position and plot them by position. But now i have counts of these types. Is there a way to compute boxplot of such kind of data ? Regards, KM [[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] Boxplot Issues
Nice boxplot but you forgot to tell us the issues :) John Kane Kingston ON Canada -Original Message- From: asir...@gmail.com Sent: Sat, 9 Feb 2013 08:09:13 -0800 To: r-help@r-project.org Subject: [R] Boxplot Issues __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot in R
How to calculate the boxplots R? This question arises because we are building manually boxplots, we consulted various literature sources for calculations of the boxplot but our results differ from those generated by R, especially when calculating the whiskers. What is the procedure used by R to perform these calculations? Anyone can help us please? -- View this message in context: http://r.789695.n4.nabble.com/Boxplot-in-R-tp4649797.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] Boxplot in R
On Nov 16, 2012, at 2:04 PM, Elli ellilti_...@hotmail.com wrote: How to calculate the boxplots R? This question arises because we are building manually boxplots, we consulted various literature sources for calculations of the boxplot but our results differ from those generated by R, especially when calculating the whiskers. What is the procedure used by R to perform these calculations? Anyone can help us please? A reading of the help page for the function using ?boxplot would be enlightening, taking note of the 'range' argument relative to the whiskers, which defaults to 1.5. The See Also on that help page points you to ?boxplot.stats which does the computation and has additional detail. Both pages list references. If all else fails, since R is open source, you can always look at the source code for both functions to follow exactly what is done. Regards, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boxplot in R
On 17/11/12 09:04, Elli wrote: How to calculate the boxplots R? This question arises because we are building manually boxplots, we consulted various literature sources for calculations of the boxplot but our results differ from those generated by R, especially when calculating the whiskers. What is the procedure used by R to perform these calculations? Anyone can help us please? ?boxplot.stats cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot of different colors
Shamelessly stealling Richard Heiberger's data set I'd suggest another way using ggplot2 which you would need to install library(ggplot2) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) p - ggplot(dataN , aes(Diet_B, GE_distance, colour = Diet_B )) + geom_boxplot() + xlab(Migration) + ylab(Distance) p John Kane Kingston ON Canada -Original Message- From: r...@temple.edu Sent: Mon, 24 Sep 2012 19:00:09 -0400 To: elaine.kuo...@gmail.com Subject: Re: [R] boxplot of different colors ## I would do this in lattice using the panel.bwplot.intermediate.hh ## function from the HH package. ## install.packages(HH) ## if necessary library(HH) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13)) On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) [[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. Send any screenshot to your friends in seconds... Works in all emails, instant messengers, blogs, forums and social networks. TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot names italic
Hello I have two boxplots and want the names to be in italic, which works fine, except that the second name (Sinapis) is raised, compared to the first name: bicran-c(0.55,0.25,0.6,0.83,0.11,0,0.67,1.36,0.9,1.09) bicsin-c(0.09,0.53,0.45,0.38,1.18,0.45,0.78,1.17,1.22,1.4) ran.text-expression(italic(Ranunculus)) sin.text-expression(italic(Sinapis)) boxplot(bicran, bicsin, names=c(ran.text, sin.text)) mtext((N=10), side=1,line=1, adj=0.43,cex=0.9) mtext((N=10),side=1,line=1,adj=0.9, cex=0.9) Is there anything I can do against that? With the names in regular letters there is no problem, the names show up on the same level: boxplot(bicran, bicsin, names=c(Ranunculus, Sinapis)) Thanks and cheers, Sarah __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot names italic
On 09/25/2012 06:08 PM, Wolf Sarah wrote: Hello I have two boxplots and want the names to be in italic, which works fine, except that the second name (Sinapis) is raised, compared to the first name: bicran-c(0.55,0.25,0.6,0.83,0.11,0,0.67,1.36,0.9,1.09) bicsin-c(0.09,0.53,0.45,0.38,1.18,0.45,0.78,1.17,1.22,1.4) ran.text-expression(italic(Ranunculus)) sin.text-expression(italic(Sinapis)) boxplot(bicran, bicsin, names=c(ran.text, sin.text)) mtext((N=10), side=1,line=1, adj=0.43,cex=0.9) mtext((N=10),side=1,line=1,adj=0.9, cex=0.9) Is there anything I can do against that? With the names in regular letters there is no problem, the names show up on the same level: boxplot(bicran, bicsin, names=c(Ranunculus, Sinapis)) Hi Sarah, Try this: boxplot(bicran, bicsin, names=c(,)) mtext(c(ran.text,sin.text),at=1:2,line=c(0.9,1),side=1) That looks about right, but you can fiddle with it. 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] boxplot of different colors
hello Richard, Thank a lot. The plot is breathtaking. I would like to make three modifications. Please kindly help and thanks. 1. making outliers from dash to empty circle (pch=2) I tried plot.symbol as the code below but failed. 2. making font size of axis (levels) larger to 1.2 unsure where to adjust in the code 3. making levels along x-axis horizontal instead of vertical unsure where to adjust in the code. Elaine Code dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) levels(dataN$Diet_B) - Diet.colors diet = list(lty=1,pch=1) bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13), scales=list(x=list(rot=90)), par.settings=list(box.umbrella=diet,plot.symbol = diet)) On Tue, Sep 25, 2012 at 11:48 AM, Richard M. Heiberger r...@temple.eduwrote: See ?panel.bwplot for pch=|. That explains that pch=| puts horizontal lines instead of dots at the median(and also at the outliers). The rep makes it into a vector to be indexed by panel.bwplot.intermediate.hh in each of its calls to panel.bwplot The names under each plot are the levels of the factor, in this example levels(Diet_B). You called them 1:13 in your example. If you want to give them names do so as a factor. For example Control the staples with box.umbrella, again see ?panel.bwplot and ?trellis.par.get The revised example here does all three of your requests. dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) levels(dataN$Diet_B) - Diet.colors bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13), scales=list(x=list(rot=90)), par.settings=list(box.umbrella=list(lty=1))) On Mon, Sep 24, 2012 at 11:13 PM, Elaine Kuo elaine.kuo...@gmail.comwrote: Hello Richard, Your answer is a great help to my problem. The boxplot of 13 colors is very beautiful :) By the way, I have three subsequent questions of your code 1. the meaning of pch=rep(|,13) I read the R manual but could not interpret the part. pch means the point type in plot, but here not sure. 2. how to write names under each box In boxplot, names can explain each box, but here names does not work. 3. how to make staple from dash to solid line Thanks again Elaine On Tue, Sep 25, 2012 at 7:00 AM, Richard M. Heiberger r...@temple.eduwrote: ## I would do this in lattice using the panel.bwplot.intermediate.hh ## function from the HH package. ## install.packages(HH) ## if necessary library(HH) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13)) On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.comwrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of
[R] boxplot of different colors
Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) [[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] boxplot of different colors
Hi Elaine, Without a reproducible example it's impossible to say, but I'd take a hard look at: table(obs.group) If that doesn't give you some insight, a small reproducible example included in your email using dput() would allow us to answer you more effectively. Sarah On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) -- Sarah Goslee http://www.functionaldiversity.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] boxplot of different colors
## I would do this in lattice using the panel.bwplot.intermediate.hh ## function from the HH package. ## install.packages(HH) ## if necessary library(HH) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13)) On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) [[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] boxplot of different colors
Hello Richard, Your answer is a great help to my problem. The boxplot of 13 colors is very beautiful :) By the way, I have three subsequent questions of your code 1. the meaning of pch=rep(|,13) I read the R manual but could not interpret the part. pch means the point type in plot, but here not sure. 2. how to write names under each box In boxplot, names can explain each box, but here names does not work. 3. how to make staple from dash to solid line Thanks again Elaine On Tue, Sep 25, 2012 at 7:00 AM, Richard M. Heiberger r...@temple.eduwrote: ## I would do this in lattice using the panel.bwplot.intermediate.hh ## function from the HH package. ## install.packages(HH) ## if necessary library(HH) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13)) On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.comwrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) [[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] boxplot of different colors
Hello Sarah, Thanks for the suggestion of table(obs.group). I checked it and found no problems of the obs.group. As for using dput(), please kindly share some examples to display the colored graph in r-help. In fact, some colors were assigned to all types of diets, like A=red1 B=red2 C=green1 D=green4 E=darkgreen F=orange3 G=darkorange2 H=navy I=blue1 However, the boxplot displays as A=red1 B=red2 C=green1 D=green4 E=red1 F=red2 G=green1 H=green4 I=red1. I am wondering if there is any bug in showing too many colors for boxplot. Elaine On Tue, Sep 25, 2012 at 6:52 AM, Sarah Goslee sarah.gos...@gmail.comwrote: Hi Elaine, Without a reproducible example it's impossible to say, but I'd take a hard look at: table(obs.group) If that doesn't give you some insight, a small reproducible example included in your email using dput() would allow us to answer you more effectively. Sarah On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.com wrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) -- Sarah Goslee 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.
[R] boxplot of multi box color
Hello, I want to draw a boxplot using 13 colors for 13 boxes. Each box represents a type of diet of birds. Y axis is the breeding range of the birds. I checked the previous r-help and found a possible solution. However, it did not work by showing error in ncol(Diet_B), Diet_B not found. Please kindly help with modification and thank you. Also, if anything is unclear, please let me know. code # data input dataN -read.csv(H:/Mig_bird_586_20120925.csv,header=T, row.names=1) dataN$Diet_B -factor(dataN$Diet_B) # graph par(mai=c(1,1.03,0.4,0.4)) boxplot(GE_distance~Diet_B, data=dataN, col = rep(seq(ncol(Diet_B)) + 1, each = 1)) [[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] boxplot of different colors
See ?panel.bwplot for pch=|. That explains that pch=| puts horizontal lines instead of dots at the median(and also at the outliers). The rep makes it into a vector to be indexed by panel.bwplot.intermediate.hh in each of its calls to panel.bwplot The names under each plot are the levels of the factor, in this example levels(Diet_B). You called them 1:13 in your example. If you want to give them names do so as a factor. For example Control the staples with box.umbrella, again see ?panel.bwplot and ?trellis.par.get The revised example here does all three of your requests. dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) levels(dataN$Diet_B) - Diet.colors bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13), scales=list(x=list(rot=90)), par.settings=list(box.umbrella=list(lty=1))) On Mon, Sep 24, 2012 at 11:13 PM, Elaine Kuo elaine.kuo...@gmail.comwrote: Hello Richard, Your answer is a great help to my problem. The boxplot of 13 colors is very beautiful :) By the way, I have three subsequent questions of your code 1. the meaning of pch=rep(|,13) I read the R manual but could not interpret the part. pch means the point type in plot, but here not sure. 2. how to write names under each box In boxplot, names can explain each box, but here names does not work. 3. how to make staple from dash to solid line Thanks again Elaine On Tue, Sep 25, 2012 at 7:00 AM, Richard M. Heiberger r...@temple.eduwrote: ## I would do this in lattice using the panel.bwplot.intermediate.hh ## function from the HH package. ## install.packages(HH) ## if necessary library(HH) dataN - data.frame(GE_distance=rnorm(260), Diet_B=factor(rep(1:13, each=20))) Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2, sienna2,red2,firebrick3,saddlebrown,coral4, chocolate4,darkblue,navy,grey38) bwplot(GE_distance ~ Diet_B, data=dataN, xlab=list(Diet of Breeding Ground, cex = 1.4), ylab = list( Distance between Centers of B and NB Range (1000 km), cex = 1.4), panel=panel.bwplot.intermediate.hh, col=Diet.colors, pch=rep(|,13)) On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.comwrote: Hello, I am making a boxplot of 13 boxes. I tried to color the box using 13 colors but failed. Only red and brown were displayed. Green, blue, and grey disappeared. Please kindly advise modification after checking the code below. Thank you in advance. Elaine R code # data input dataN -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T, row.names=1) dim(dataN) dataN[1,] str(dataN) # graph par(mai=c(1,1.03,0.4,0.4)) obs.group-dataN$Diet_B par(new=T) boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet of Breeding Ground,ylab=, yaxt=n,type=p, pch=1,lwd=0.95, cex.lab=1.4, cex.axis=1.2, font.axis=2, cex=1.5, las=1, bty=l, col=c(forestgreen, darkgreen,chocolate1,darkorange2,sienna2, red2,firebrick3, saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group])) op = par(mar = c(5,5,4,2) + 0.1) title(ylab = Distance between Centers of B and NB Range (1000 km), cex.lab = 1.4,line = 3) axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2, las=1) [[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] Boxplot lattice vs standard graphics
ok, I see now! here it is the reproducible example along with the final code (aslo with the median line instead of a point) thank you all for the great help max # start code library(lattice) test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, B, C, D, E), class = factor), conc = c(2.32, 0.902, 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 3.39, 20, 4.59)), .Names = c(site, conc), row.names = c(NA, 52L), class = data.frame) mystats - function(x, ...){ # Here ... out - boxplot.stats(10^x, ...) # ...and here!!! out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out ## With the boxplot statistics converted to the log10 scale } dev.new() bwplot(conc~site, data=test, pch=|, # this is plotting a line instead of a point scales = list(y=list(log=10)), panel = function(...){ panel.bwplot(..., stats = mystats) } ) # end code Il 17/09/2012 20:26, Rui Barradas ha scritto: Hello, Em 17-09-2012 18:50, David Winsemius escreveu: On Sep 17, 2012, at 4:18 AM, maxbre wrote: here it is, I think (I hope) I'm getting a little closer with this, but still there is something to sort out... error using packet 1 unused argument(s) (coef =1.5, do.out=TRUE) by reading the help for panel.bwplot at the argument stats it says: the function must accept arguments coef and do.out even if they do not use them (a ... argument is good enough). I'm not sure how to couple with this... any help for this ? thanks ## start code mystats - function(x){ out - boxplot.stats(10^x) out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out$coef-1.5 #?? out$do.out-TRUE #?? out ## With the boxplot statistics converted to the log10 scale } bwplot(conc~site, data=test, scales=list(y=list(log=10)), panel= function(x,y){ panel.bwplot(x,y,stats=mystats) } ) No example data, so no efforts at running code. Actually there is, in the op. ?panel.bwplot # Notice the Usage at the top of the page. The ... is there for a reason. # And notice that neither 'do.out' nor 'coef' are passed in the stats list # The message was talking about what arguments your 'mystats' would accept, not what it would return. It's another instance of your needing to understand what the ... formalism is doing. ?boxplot.stats # I would be making a concerted effort to return a list with exactly the components listed there. And since I'm terrible at graphics I try to learn as much as possible on R-Help. Here it goes. library(lattice) test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, B, C, D, E), class = factor), conc = c(2.32, 0.902, 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 3.39, 20, 4.59)), .Names = c(site, conc), row.names = c(NA, 52L), class = data.frame) #standard graphics dev.new() with(test,boxplot(conc~site, log=y)) #lattice mystats - function(x, ...){ # Here ... out - boxplot.stats(10^x, ...) # ...and here!!! out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out ## With the boxplot statistics converted to the log10 scale } dev.new() bwplot(conc~site, data=test, scales = list(y=list(log=10)), panel = function(...){ panel.bwplot(..., stats = mystats) } ) With a median _line_ it would be perfect. (Not a follow-up, it was already answered some time ago, use pch = | in panel.bwplot.) Rui Barradas ## end 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] Boxplot lattice vs standard graphics
thank you for the help, bert unfortunately, for reasons I can not understand (yet) I can not put to wortk it all (I'm always in trouble with the panel functions); max Il 14/09/2012 18:38, Bert Gunter ha scritto: Thanks for the example. Makes it easy to see what you mean. Yes, if I understand you correctly, you are right: boxplot() (base) transforms the axes, so ?boxplot.stats, which is the function that essentially computes the boxplot, does so on the original data. bwplot(lattice) transforms the data first, as the documentation for the log component of the scales list makes clear, and **then** calls boxplot.stats. Although I think the latter makes more sense then the former, I think the way to do it is to modify the stats function in an explicit call to panel.bwplot to something like (UNTESTED!) mystats - function(x){ out - boxplot.stats(10^x) out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out ## With the boxplot statistics converted to the log10 scale } I leave it to you to test and modify as necessary. Cheers, Bert On Fri, Sep 14, 2012 at 2:37 AM, maxbre mbres...@arpa.veneto.it wrote: Given my reproducible example test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, B, C, D, E), class = factor), conc = c(2.32, 0.902, 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 3.39, 20, 4.59)), .Names = c(site, conc), row.names = c(NA, 52L), class = data.frame) And the following code #standard graphics with(test,boxplot(conc~site, log=y)) #lattice bwplot(conc~site, data=test, scales=list(y=list(log=10)) ) There is an evident difference for site A, B, D in the way some outliers are plotted by comparing the plot produced by lattice vs. the standard graphics I think to understand this might be due to the different treatment of data: i.e. log transformation (before or after the plotting?) Is it possible to achieve the same plotting result with both graphic facilities? I would like to show the outliers also in lattice… Thank you http://r.789695.n4.nabble.com/file/n4643121/standard.png http://r.789695.n4.nabble.com/file/n4643121/lattice.png -- View this message in context: http://r.789695.n4.nabble.com/Boxplot-lattice-vs-standard-graphics-tp4643121.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] Boxplot lattice vs standard graphics
here it is, I think (I hope) I'm getting a little closer with this, but still there is something to sort out... error using packet 1 unused argument(s) (coef =1.5, do.out=TRUE) by reading the help for panel.bwplot at the argument stats it says: the function must accept arguments coef and do.out even if they do not use them (a ... argument is good enough). I'm not sure how to couple with this... any help for this ? thanks ## start code mystats - function(x){ out - boxplot.stats(10^x) out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out$coef-1.5 #?? out$do.out-TRUE #?? out ## With the boxplot statistics converted to the log10 scale } bwplot(conc~site, data=test, scales=list(y=list(log=10)), panel= function(x,y){ panel.bwplot(x,y,stats=mystats) } ) ## end code -- View this message in context: http://r.789695.n4.nabble.com/Boxplot-lattice-vs-standard-graphics-tp4643121p4643357.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] Boxplot lattice vs standard graphics
On Sep 17, 2012, at 4:18 AM, maxbre wrote: here it is, I think (I hope) I'm getting a little closer with this, but still there is something to sort out... error using packet 1 unused argument(s) (coef =1.5, do.out=TRUE) by reading the help for panel.bwplot at the argument stats it says: the function must accept arguments coef and do.out even if they do not use them (a ... argument is good enough). I'm not sure how to couple with this... any help for this ? thanks ## start code mystats - function(x){ out - boxplot.stats(10^x) out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out$coef-1.5 #?? out$do.out-TRUE #?? out ## With the boxplot statistics converted to the log10 scale } bwplot(conc~site, data=test, scales=list(y=list(log=10)), panel= function(x,y){ panel.bwplot(x,y,stats=mystats) } ) No example data, so no efforts at running code. ?panel.bwplot # Notice the Usage at the top of the page. The ... is there for a reason. # And notice that neither 'do.out' nor 'coef' are passed in the stats list # The message was talking about what arguments your 'mystats' would accept, not what it would return. It's another instance of your needing to understand what the ... formalism is doing. ?boxplot.stats # I would be making a concerted effort to return a list with exactly the components listed there. ## end code -- David Winsemius, MD Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Boxplot lattice vs standard graphics
Hello, Em 17-09-2012 18:50, David Winsemius escreveu: On Sep 17, 2012, at 4:18 AM, maxbre wrote: here it is, I think (I hope) I'm getting a little closer with this, but still there is something to sort out... error using packet 1 unused argument(s) (coef =1.5, do.out=TRUE) by reading the help for panel.bwplot at the argument stats it says: the function must accept arguments coef and do.out even if they do not use them (a ... argument is good enough). I'm not sure how to couple with this... any help for this ? thanks ## start code mystats - function(x){ out - boxplot.stats(10^x) out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out$coef-1.5 #?? out$do.out-TRUE #?? out ## With the boxplot statistics converted to the log10 scale } bwplot(conc~site, data=test, scales=list(y=list(log=10)), panel= function(x,y){ panel.bwplot(x,y,stats=mystats) } ) No example data, so no efforts at running code. Actually there is, in the op. ?panel.bwplot # Notice the Usage at the top of the page. The ... is there for a reason. # And notice that neither 'do.out' nor 'coef' are passed in the stats list # The message was talking about what arguments your 'mystats' would accept, not what it would return. It's another instance of your needing to understand what the ... formalism is doing. ?boxplot.stats # I would be making a concerted effort to return a list with exactly the components listed there. And since I'm terrible at graphics I try to learn as much as possible on R-Help. Here it goes. library(lattice) test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, B, C, D, E), class = factor), conc = c(2.32, 0.902, 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 3.39, 20, 4.59)), .Names = c(site, conc), row.names = c(NA, 52L), class = data.frame) #standard graphics dev.new() with(test,boxplot(conc~site, log=y)) #lattice mystats - function(x, ...){ # Here ... out - boxplot.stats(10^x, ...) # ...and here!!! out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out ## With the boxplot statistics converted to the log10 scale } dev.new() bwplot(conc~site, data=test, scales = list(y=list(log=10)), panel = function(...){ panel.bwplot(..., stats = mystats) } ) With a median _line_ it would be perfect. (Not a follow-up, it was already answered some time ago, use pch = | in panel.bwplot.) Rui Barradas ## end 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] Boxplot lattice vs standard graphics
Thanks for the example. Makes it easy to see what you mean. Yes, if I understand you correctly, you are right: boxplot() (base) transforms the axes, so ?boxplot.stats, which is the function that essentially computes the boxplot, does so on the original data. bwplot(lattice) transforms the data first, as the documentation for the log component of the scales list makes clear, and **then** calls boxplot.stats. Although I think the latter makes more sense then the former, I think the way to do it is to modify the stats function in an explicit call to panel.bwplot to something like (UNTESTED!) mystats - function(x){ out - boxplot.stats(10^x) out$stats - log10(out$stats) out$conf - log10(out$conf) ## Omit if you don't want notches out$out - log10(out$out) out ## With the boxplot statistics converted to the log10 scale } I leave it to you to test and modify as necessary. Cheers, Bert On Fri, Sep 14, 2012 at 2:37 AM, maxbre mbres...@arpa.veneto.it wrote: Given my reproducible example test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, B, C, D, E), class = factor), conc = c(2.32, 0.902, 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 3.39, 20, 4.59)), .Names = c(site, conc), row.names = c(NA, 52L), class = data.frame) And the following code #standard graphics with(test,boxplot(conc~site, log=y)) #lattice bwplot(conc~site, data=test, scales=list(y=list(log=10)) ) There is an evident difference for site A, B, D in the way some outliers are plotted by comparing the plot produced by lattice vs. the standard graphics I think to understand this might be due to the different treatment of data: i.e. log transformation (before or after the plotting?) Is it possible to achieve the same plotting result with both graphic facilities? I would like to show the outliers also in lattice… Thank you http://r.789695.n4.nabble.com/file/n4643121/standard.png http://r.789695.n4.nabble.com/file/n4643121/lattice.png -- View this message in context: http://r.789695.n4.nabble.com/Boxplot-lattice-vs-standard-graphics-tp4643121.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Boxplot lattice vs standard graphics
Given my reproducible example test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, B, C, D, E), class = factor), conc = c(2.32, 0.902, 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 3.39, 20, 4.59)), .Names = c(site, conc), row.names = c(NA, 52L), class = data.frame) And the following code #standard graphics with(test,boxplot(conc~site, log=y)) #lattice bwplot(conc~site, data=test, scales=list(y=list(log=10)) ) There is an evident difference for site A, B, D in the way some outliers are plotted by comparing the plot produced by lattice vs. the standard graphics I think to understand this might be due to the different treatment of data: i.e. log transformation (before or after the plotting?) Is it possible to achieve the same plotting result with both graphic facilities? I would like to show the outliers also in lattice… Thank you http://r.789695.n4.nabble.com/file/n4643121/standard.png http://r.789695.n4.nabble.com/file/n4643121/lattice.png -- View this message in context: http://r.789695.n4.nabble.com/Boxplot-lattice-vs-standard-graphics-tp4643121.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] boxplot - bclust
These are warnings and I think that you can safely ignore them. It looks like the code should replace the line if (x$datamean) with something like if (!is.null(x$datamean)) Yes, I think so too - thanks for reporting this. David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] boxplot of hierachical cluster
Hello everybody, I would like to make boxplots for my hierachical cluster, but only i found a package that not works with the current version. http://acccn.net/cr569/Rstuff/Minka/mining/html/boxplot.hclust.html I hope you can help me. Thank you. Best regards, Dominic library(cluster) cluster.Invierno - daisy(datos.corre[,-3],metric=gower,stand=TRUE) plot(hclust(cluster.Invierno),labels=datos.corre[,1]) str(datos.corre[,-3]) 'data.frame': 56 obs. of 6 variables: $ Estacion: Factor w/ 56 levels Abradelo,AltoDoRodicio,..: 1 2 3 4 5 6 7 8 9 10 ... $ Invierno: num 36 53.9 37.1 63.6 12.5 ... $ X : int 643449 616292 562796 669916 625025 631194 511201 524431 641809 590324 ... $ X.1 : int 4734442 4684126 4696309 4743224 4723028 4833932 4649389 4701030 4706108 4765782 ... $ X.2 : int 826 981 553 1364 432 421 473 424 697 731 ... $ X.3 : num 87961 82902 30608 84260 94169 ... [[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] boxplot - bclust
Hello everybody, I have a problem with the commando of boxplot -bclust. http://127.0.0.1:13155/library/e1071/html/boxplot.bclust.html data(iris) bc1 - bclust(iris[,1:4], 3, base.centers=5) Committee Member: 1(1) 2(1) 3(1) 4(1) 5(1) 6(1) 7(1) 8(1) 9(1) 10(1) Computing Hierarchical Clustering boxplot(bc1) Warnmeldungen: 1: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt (Condition has length 1 and only the first element is used) # It's normal? Why? 2: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt 3: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt Thank you for your help. Best regards, Dominic [[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] boxplot - bclust
On 2012-09-03 08:34, Dominic Roye wrote: Hello everybody, I have a problem with the commando of boxplot -bclust. http://127.0.0.1:13155/library/e1071/html/boxplot.bclust.html data(iris) bc1 - bclust(iris[,1:4], 3, base.centers=5) Committee Member: 1(1) 2(1) 3(1) 4(1) 5(1) 6(1) 7(1) 8(1) 9(1) 10(1) Computing Hierarchical Clustering boxplot(bc1) Warnmeldungen: 1: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt (Condition has length 1 and only the first element is used) # It's normal? Why? 2: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt 3: In if (x$datamean) { : Bedingung hat Länge 1 und nur das erste Element wird benutzt These are warnings and I think that you can safely ignore them. It looks like the code should replace the line if (x$datamean) with something like if (!is.null(x$datamean)) Peter Ehlers Thank you for your help. Best regards, Dominic [[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] boxplot help
Hi, im a newbie with very wobbly coding abilities. Tearing my hair out over getting the boxplot i want... I have a dataset called 'eagle' which consists of year (2011 or 2012), month (jan - dec), roof (TT6, TT13 or BARE) and temp (the continuous variable that i want to plot). So i want boxplots of the three roof treatments in every month organised in chronical order along x axis 2011 - 2012. my code at the moment is: boxplot(Temp~Month, data=eagle, at = 1:12 - 0.5, boxwex=0.25, subset=Roof == TT6, col = green) boxplot(Temp~Month, data=eagle, add=TRUE, at = 1:12 - 0.1, boxwex = 0.25, subset=Roof == TT13, col = darkgreen) boxplot(Temp~Month, data=eagle, add=TRUE, boxwex=0.25, at = 1:12 + 0.2, subset=Roof == BARE, col = red) smartlegend(x=left,y=top, inset = 0, c(green 1, green 2, bare), fill = c(green, darkgreen, red)) which produces the graph inserted Can anyone point me in right direction? thanks http://r.789695.n4.nabble.com/file/n4640360/boxplot_trial.jpg -- View this message in context: http://r.789695.n4.nabble.com/boxplot-help-tp4640360.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] boxplot help
Hi Andy, Nice plot but yes, probably not exactly what you want. Thanks for providing the code. The nextthing you need to do is to send us some data to go with the code. There is a very handy function called dput() , which converts a dataset into a format that you can just copy from your R terminal and paste into an email that allows readers to work wiith your data or a sample of it. If the dataset is really large then something like dput(head (mydata, 50)) will supply the first fifty rows of data for us to work with. One of your problems seems to be that your dates are character values and need to be converted into datesfor you to get the chronological date order. See ?strptime or perhaps install the lubridate package for help there. Otherwise welcome to R Note to other readers : I think I actually got the dput syntax this time!! John Kane Kingston ON Canada -Original Message- From: freakyspe...@hotmail.com Sent: Wed, 15 Aug 2012 05:34:55 -0700 (PDT) To: r-help@r-project.org Subject: [R] boxplot help Hi, im a newbie with very wobbly coding abilities. Tearing my hair out over getting the boxplot i want... I have a dataset called 'eagle' which consists of year (2011 or 2012), month (jan - dec), roof (TT6, TT13 or BARE) and temp (the continuous variable that i want to plot). So i want boxplots of the three roof treatments in every month organised in chronical order along x axis 2011 - 2012. my code at the moment is: boxplot(Temp~Month, data=eagle, at = 1:12 - 0.5, boxwex=0.25, subset=Roof == TT6, col = green) boxplot(Temp~Month, data=eagle, add=TRUE, at = 1:12 - 0.1, boxwex = 0.25, subset=Roof == TT13, col = darkgreen) boxplot(Temp~Month, data=eagle, add=TRUE, boxwex=0.25, at = 1:12 + 0.2, subset=Roof == BARE, col = red) smartlegend(x=left,y=top, inset = 0, c(green 1, green 2, bare), fill = c(green, darkgreen, red)) which produces the graph inserted Can anyone point me in right direction? thanks http://r.789695.n4.nabble.com/file/n4640360/boxplot_trial.jpg -- View this message in context: http://r.789695.n4.nabble.com/boxplot-help-tp4640360.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. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot help
Hi, I recommend the use of panel.bwplot.intermediate.hh in the HH package. This is a lattice function. Lattice usually gives you more control than base graphics. I build your example in several steps here. Critical items to notice: You must declare the months to be ordered; by default they are sorted alphabetically. The position() function in the HH package gives control of the spacing of factor levels in an axis. The default axis labels are overprinting. By displaying only the 2, 5, ... label, and by grouping the three group levels within each month, you get a more readable graph. In your jpg example, there are an excess of outliers. Please be sure to understand what they represent. Rich ## install.packages(HH) ## if needed library(HH) mycolors - c(lightgreen, darkgreen, red) tmp - data.frame(y=rnorm(612), month=rep(ordered(month.abb, levels=month.abb), 51), group=rep(ordered(mycolors, levels=mycolors), 3, each=17)) gm - with(tmp, interaction(group, month)) bwplot(y ~ month | group, data=tmp, main=first attempt, layout=c(3,1)) bwplot(y ~ gm, data=tmp, col=mycolors, main=second attempt) bwplot(y ~ gm, data=tmp, col=mycolors, main=third attempt, panel=panel.bwplot.intermediate.hh) bwplot(y ~ gm, data=tmp, col=mycolors, main=fourth attempt, panel=panel.bwplot.intermediate.hh, key=list( text=list(mycolors, col=mycolors), space=right, border=TRUE, title=Group Name,cex.title=.9), scales=list(x=list(at=(3*(1:12)-1), labels=month.abb))) position(gm) - as.vector(outer(c(-.8,0,.8), (3*(1:12)-1), +)) bwplot(y ~ gm, data=tmp, col=mycolors, panel=panel.bwplot.intermediate.hh, key=list( text=list(mycolors, col=mycolors), space=right, border=TRUE, title=Group Name,cex.title=.9), scales=list(x=list(at=(3*(1:12)-1), labels=month.abb)), main=fifth: what you asked for) On Wed, Aug 15, 2012 at 8:34 AM, andyspeak freakyspe...@hotmail.com wrote: Hi, im a newbie with very wobbly coding abilities. Tearing my hair out over getting the boxplot i want... I have a dataset called 'eagle' which consists of year (2011 or 2012), month (jan - dec), roof (TT6, TT13 or BARE) and temp (the continuous variable that i want to plot). So i want boxplots of the three roof treatments in every month organised in chronical order along x axis 2011 - 2012. my code at the moment is: boxplot(Temp~Month, data=eagle, at = 1:12 - 0.5, boxwex=0.25, subset=Roof == TT6, col = green) boxplot(Temp~Month, data=eagle, add=TRUE, at = 1:12 - 0.1, boxwex = 0.25, subset=Roof == TT13, col = darkgreen) boxplot(Temp~Month, data=eagle, add=TRUE, boxwex=0.25, at = 1:12 + 0.2, subset=Roof == BARE, col = red) smartlegend(x=left,y=top, inset = 0, c(green 1, green 2, bare), fill = c(green, darkgreen, red)) which produces the graph inserted Can anyone point me in right direction? thanks http://r.789695.n4.nabble.com/file/n4640360/boxplot_trial.jpg -- View this message in context: http://r.789695.n4.nabble.com/boxplot-help-tp4640360.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot help
hi thanks the dput output is... structure(list(Year = c(2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L), Month = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(Apr, Aug, Dec, Feb, Jan, Jul, Jun, Mar, May, Nov, Oct, Sep), class = factor), Roof = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c(BARE, TT13, TT6), class = factor), Temp = c(10.68, 11.8, 12.16, 12.36, 12.5, 12.58, 12.46, 12.72, 12.31, 12.35, 12.44, 12.59, 12.86, 13.05, 13.83, 13.92, 14.24, 14.47, 13.84, 13.44, 12.83, 12.73, 12.47, 12.18, 12.59, 12.36, 12.09, 11.73, 13.02, 13.16, 13.21, 13.53, 14.15, 14.67, 15.53, 15.48, 17.43, 18.56, 22.6, 25.06, 20.36, 18.78, 15.29, 11.98, 10.23, 9.42, 8.38, 7.37, 6.47, 6.3)), .Names = c(Year, Month, Roof, Temp), row.names = c(NA, 50L), class = data.frame) But as this is only first 50 rows then it doesnt show that some of the data is Jan - Jul of 2012 which i want displaying separately from Apr-Jul 2011 data. I think the next reply i recieved points me to a good solution. -- View this message in context: http://r.789695.n4.nabble.com/boxplot-help-tp4640360p4640392.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.