[R] data.frame to array?
hadley wickham
h.wickham at gmail.com
Fri Apr 3 21:52:30 CEST 2009
On Fri, Apr 3, 2009 at 1:45 PM, <rkevinburton at charter.net> wrote:
> I have a list of data.frames
>
>> str(bins)
>
> List of 19217
> $ 100026:'data.frame': 1 obs. of 6 variables:
> ..$ Sku : chr "100026"
> ..$ Bin : chr "T149C"
> ..$ Count: int 108
> ..$ X : int 20
> ..$ Y : int 149
> ..$ Z : chr "3"
> $ 100030:'data.frame': 1 obs. of 6 variables:
> .......
> As you can see one 'column' is "Count". This list seems to contain 19217 data.frames. I would like to create an array of 19217 integers which hold the values of the "Count" column. I have tried the obvious (to me):
>
> bins[[1:3]]$Count
>
> But that returns NULL instead of an array of length 3 that I was expecting. Interestingly bins[[1]]$Count returns the first "Count" in the list of data frames. How do I get all of the "Count"s?
Why not turn your list of data frames into a single data frame?
bindf <- do.call("rbind", bins)
bindf$Count
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list