List of lists???

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

List of lists???

Stéphane CRUVEILLER-2
Hi,

I would like to perform computations on some variables belonging to the same
dataframe. For instance my data frame has the following shape:
        toto1   toto2   toto3   toto4   toto5
1       1       2       3       4       5
2       6       7       8       9       10

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 a 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: [hidden email] ,[hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: List of lists???

Gabor Grothendieck
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 <[hidden email]> 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: [hidden email] ,[hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: List of lists???

Stéphane CRUVEILLER-2
Thx for the hint...
the div <- factor(c(1,1,1,2,2)) did exactly what I was expecting...

Stéphane.

Le Mardi 31 Janvier 2006 15:50, Gabor Grothendieck a écrit :

> 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 <[hidden email]> 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: [hidden email] ,[hidden email]
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html

--
==========================================================
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: [hidden email] ,[hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html