[R] write data frame in a list

jim holtman jholtman at gmail.com
Tue Nov 10 13:58:23 CET 2009


Is this what you want:

> df=data.frame(x=c(3,6,7),y=c(2,7,4))
> df
  x y
1 3 2
2 6 7
3 7 4
> as.list(df)
$x
[1] 3 6 7

$y
[1] 2 7 4


On Tue, Nov 10, 2009 at 6:05 AM, Grzes <gregorio99 at gmail.com> wrote:
>
> Hi,
> I have got a data frame:
>
> df=data.frame(x=c(3,6,7),y=c(2,7,4))
>
> and I would like to write my values from data frame to list using loop, for
> example:
>
> lista=list()
> for (i in 1: length(?)){
>        lista[[?]][?] = df [?]
> }
> But I havn't got any idea what I should put in places where I put a question
> mark?
>
> As a rusult I would like to get a list like this:
> list:
> [[1]]
> 3,6,7
> [[2]]
> 2,7,4
>
> I wll be very happy if somebody can help me
>
>
> --
> View this message in context: http://old.nabble.com/write-data-frame-in-a-list-tp26281645p26281645.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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list