[R] extracting submatrix from a bigger one

Bert Gunter gunter.berton at gene.com
Mon Jun 24 20:42:17 CEST 2013


Inline below...

On Mon, Jun 24, 2013 at 11:31 AM, matteo <matteo.ghetta at gmail.com> wrote:
> First of all, thanks for all the replies!!
> What you have written helps, but is not entirely the answer to my problem.
>
> What I'd have is the creation of new data.frames each of one named with the
> ID of the original dataframe and with all the columns.

No you don't! You want what you were provided, a list of data frames.
Anything you want to do can be done, probably more conveniently, with
that.

Read "An Introduction to R" and learn to work with lists. Being a
newbie is no excuse for not making an effort to learn.

-- Bert



>
> For example, in the original dataframe one column (ID) has 5 different
> elements:
>
> ID    value1    value2
> x1        10            12
> x1        12            22
> x1        11            9
> x2        15            10
> x3        11            11
> x3        13            8
>
> I need a command ables to split the dataframe in other smallest and
> separated dataframes, so that they look like
>
> x1 is
> ID    value1    value2
> x1        10            12
> x1        12            22
> x1        11            9
>
> x2 is
> ID    value1    value2
> x2        15            10
>
> and x3 is
> ID    value1    value2
> x1        10            12
> x3        11            11
> x3        13            8
>
>
> Sorry if I'm not able to explain it better and as I said I'm very new to
> R.....
>
> Thanks
>
> Matteo



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list