[R] R-help,

Sean Davis sdavis2 at mail.nih.gov
Thu May 19 13:30:40 CEST 2005


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

> 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))
>

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)
}
)



>
> HTH
>
> Jean
> On Thu, 19 May 2005, Luis Ridao Cruz wrote:
>
>> 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
>>
>>> version
>>          _
>> 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
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://www.R-project.org/posting-guide.html
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list