[R] writing elements in list as a data frame

Srinivas Iyyer srini_iyyer_bio at yahoo.com
Wed Sep 5 23:48:48 CEST 2007


Dear R-helpers, 
Lists in R are stumbling block for me.

I kindly ask you to help me able to write a
data-frame. 

I have a list of lists. 

> sls[1:2]
$Andromeda_maya1
       x   y
[1,] 369 103
[2,] 382 265
[3,] 317 471
[4,] 169 465
[5,] 577 333

$Andromeda_maya2
        x   y
 [1,] 173 507
 [2,] 540 395
 [3,] 268 143
 [4,] 346 175
 [5,] 489  91
 
I want to be able to write a data.frame like the
following:
X   Y     Name
369 103  Andromeda_maya1
382 265  Andromeda_maya1
317 471  Andromeda_maya1
169 465  Andromeda_maya1
577 333  Andromeda_maya1
173 507  Andromeda_maya2
540 395  Andromeda_maya2
268 143  Andromeda_maya2
346 175  Andromeda_maya2
489  91  Andromeda_maya2

Is there a way to convert this list-of-list into a
data.frame.

Thanks
srini



More information about the R-help mailing list