[R] List of lists???

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jan 31 15:50:07 CET 2006


Your post seems to be messed up but I will assume you have a
5 column data frame and the questino is how to run f on the first
three columns and separately on the last two.  I think the
easiest is just the following where I have used the builtin iris
data set where I have assumed that the operation you want
to perform is summary for purposes of example:

summary(iris[,1:3])
summary(iris[,4:5])

If this is not your real problem and the real problem has many more
divisions then try this where div is a factor that defines the division
of columns into sets:

div <- factor(c(1,1,1,2,2))
lapply(split(names(iris), div), function(n) summary(iris[n]))




On 1/31/06, Stephane CRUVEILLER <scruveil at genoscope.cns.fr> wrote:
> Hi,
>
> I would like to perform computations on some variables belonging to the same
> dataframe. For instance my data frame has the following shape:
> toto1toto2toto3toto4toto5
> 1 12345
> 2678910
>
> I would like to perform the calculation on c("toto1","toto2","toto3") and then
> the same calculation on c("toto4","toto5"). Is there a way to tell R to do it
> using 3 loop (a list of lists)??
>
> Stephane.
> --
> ==========================================================
> Stephane CRUVEILLER Ph. D.
> Genoscope - Centre National de Sequencage
> Atelier de Genomique Comparative
> 2, Rue Gaston Cremieux   CP 5706
> 91057 Evry Cedex - France
> Phone: +33 (0)1 60 87 84 58
> Fax: +33 (0)1 60 87 25 14
> EMails: scruveil at genoscope.cns.fr ,scruvell at infobiogen.fr
>
> ______________________________________________
> 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