[R] How to deal with a dataframe within a dataframe?

Robert Latest boblatest at gmail.com
Wed May 9 08:40:09 CEST 2012


On Tue, May 8, 2012 at 3:38 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> So this actually looks like something of a tricky one: if you wouldn't
> mind sending the result of dput(head(agg)) I can confirm, but here's
> my hunch:

Hi Michael,

while I'm trying to get my head around the rest of your post, here's
the output of dput():

> dput(head(agg))
structure(list(`df$quarter` = c("09Q3", "10Q1", "10Q2", "10Q3",
"11Q1", "11Q2"), `df$tool` = structure(c(1L, 1L, 1L, 1L, 1L,
1L), .Label = c("VS1A", "VS1B", "VS2A", "VS2B", "VS3A", "VS3B",
"VS4A", "VS4B", "VS5B"), class = "factor"), `df$value` = structure(list(
    `0` = c(1.80053430839867, 1.62848325226279), `1` = c(1.29965212329278,
    1.26130173276939), `2` = c(1.69901753654472, 1.38156952313768
    ), `3` = c(1.31168126092175, 1.06723157138633), `4` = c(1.54165763354293,
    1.21619657757276), `5` = c(1.29925171313276, 1.18276707678292
    )), .Names = c("0", "1", "2", "3", "4", "5"))), .Names = c("df$quarter",
"df$tool", "df$value"), row.names = c(NA, 6L), class = "data.frame")
>

I would like this in either the form of a "flat" data frame (i.e., the
contents of "df$value" as two separate columns), or -- even preferable
-- learn a better way to retrieve multiple numeric results from a call
to aggregate().

Thanks,
robert



More information about the R-help mailing list