Skip to content

R-help,

3 messages · Luis Ridao Cruz, Jean Eid, Sean Davis

#
R-help,

I usually call lapply to plot some dat frames structures.Something like
this:

par(mfrow=c(4,3),mar=c(2, 4, 2, 1) + 0.1)
lapply(my.list , function(x)
{
plot(colnames(x) , apply(x,2,mean),  type="o", pch = 16, ylab = "Index"
, xlab = "")
}
)

But it is difficult for me to put a title on every plot according to
the list names.
I guess the re other ways to do it but the structure above is so handy
to me that I want to stick to it.

Any suggestions?


I run on Windows XP machine
_              
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    2              
minor    1.0            
year     2005           
month    04             
day      18             
language R   


Thanks in advance
#
I do not fully understand your example but if you need to act on the
columns of a dataframe why don't you just call its columns the title you
want. something like
X<-matrix(rnorm(1000), ncol=4)
colnames(X)<-c("foo", "foo1", "foo2", "foo3")
X<-as.data.frame(X)
par(mfrow=c(2,2))
lapply(colnames(X), function(x) plot(X[,x], ylab="y", xlab="x", main=x))


HTH

Jean
On Thu, 19 May 2005, Luis Ridao Cruz wrote:

            
#
On May 19, 2005, at 7:01 AM, Jean Eid wrote:

            
Taking this back a bit to the original question:

par(mfrow=c(4,3),mar=c(2, 4, 2, 1) + 0.1)
sapply(names(my.list) , function(x)
{
plot(colnames(my.list[[x]]) , apply(my.list[[x]],2,mean),  type="o", 
pch = 16, ylab = "Index"
, xlab = "",main=x)
}
)