Tena koe Herwig
I am guessing that you are not using the terms 'table' and
'list' in the
R sense, and suggest you might want either the reshape() function or
Hadley Wickham's 'reshape' package.
For the former, if your data is in a data.frame (which is a special type
of list) then:
> herwig
A B C D
x 10 20 30 40
y 11 21 31 41
z 12 NA 32 42> str(herwig)
'data.frame': 3 obs. of 4 variables:
$ A: int 10 11 12
$ B: int 20 21 NA
$ C: int 30 31 32
$ D: int 40 41 42> reshape(herwig, varying=list(1:4), direction='long',
ids=row.names(herwig),
times=names(herwig))
time A id
x.A A 10 x
y.A A 11 y
z.A A 12 z
x.B B 20 x
y.B B 21 y
z.B B NA z
x.C C 30 x
y.C C 31 y
z.C C 32 z
x.D D 40 x
y.D D 41 y
z.D D 42 z
HTH ....
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of herwig
> Sent: Wednesday, 1 April 2009 9:03 a.m.
> To: r-help at r-project.org
> Subject: [R] convert table to list
>
>
> Hi there,
>
> This is probably a rather simple question - but I was not
> able to solve it so far.
> I would like to convert the following table:
>
> A B C D
> x 10 20 30 40
> y 11 21 31 41
> z 12 32 42
>
>
> to a list with three columns like:
>
> A x 10
> A y 11
> A z 12
> B x 20
> .
> .
> .
>
> Any hints how do do this in R would be very much apprechiated.
>
> cheers,
>
> Herwig
>
> --
> View this message in context:
> http://www.nabble.com/convert-table-to-list-tp22810143p22810143.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
The contents of this e-mail are confidential and may be subject to legal
privilege.
If you are not the intended recipient you must not use, disseminate, distribute
or
reproduce all or any part of this e-mail or attachments. If you have received
this
e-mail in error, please notify the sender and delete all material pertaining to
this
e-mail. Any opinion or views expressed in this e-mail are those of the
individual
sender and may not represent those of The New Zealand Institute for Plant and
Food Research Limited.