Re: [R] lapply and boxplots with variable names

2010-06-22 Thread Henrique Dallazuanna
Try this: library(lattice) bwplot(values ~ TimePeriod | ind, cbind(stack(my.data), TimePeriod = my.data$TimePeriod)) On Tue, Jun 22, 2010 at 1:45 PM, Shawn Morrison < shawn.morri...@dryasresearch.com> wrote: > Hi all, > > I have a dataset with several variables, each of which is a separate > col

Re: [R] lapply and boxplots with variable names

2010-06-22 Thread Shawn Morrison
Thanks Josh, I do want to see each plot. I took your code and modified it (below) and it appears to do what I wanted: my.data <- data.frame(var1=rnorm(1000), var2=rnorm(1000), TimePeriod=factor(rep((LETTERS[1:4]), 250))) str(my.data) lapply(names(my.data[ , 1:2]), function(y) { quartz() bo

Re: [R] lapply and boxplots with variable names

2010-06-22 Thread Joshua Wiley
Hello Shawn, Does this do what you want? I'm assuming you want to look at each plot, so I added a call to par(). ### my.data <- data.frame(var1=rnorm(1000), var2=rnorm(1000), TimePeriod=factor(rep((LETTERS[1:4]), 250))) str(my.data) lapply(names(my.data[ , 1:2]), function(y) { old.par <-

Re: [R] lapply and boxplots with variable names

2010-06-22 Thread Shawn Morrison
Many thanks Phil, that does help. If I could ask a follow-up, how do I put each plot in its own device window? Right now, all I get is the boxplot for var2 (var1 gets overwritten?). I tried putting quartz() before the boxplot command but got an error message. Cheers, Shawn On 22/06/10 11:13

Re: [R] lapply and boxplots with variable names

2010-06-22 Thread Phil Spector
Shawn - Does this example help? (Please don't use cbind when creating a data frame, since it first creates a matrix, which means everything must be of the same mode.) var1 = rnorm(1000) var2 = rnorm(1000) TimePeriod = rep((LETTERS[1:4]), 250) my.data = data.frame(var1,var2,TimePeriod) lapply

[R] lapply and boxplots with variable names

2010-06-22 Thread Shawn Morrison
Hi all, I have a dataset with several variables, each of which is a separate column. For each variable, I want to produce a boxplot and include the name of the variable (ie, column name) on each plot. I have included a sample dataset below. Can someone tell me where I am going wrong? Thank