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

Gabor Grothendieck ggrothendieck at gmail.com
Wed May 9 16:10:34 CEST 2012


On Tue, May 8, 2012 at 9:19 AM, Robert Latest <boblatest at gmail.com> wrote:
> Hello all,
>
> I am doing an aggregation where the aggregating function returns not a
> single numeric value but a vector of two elements using return(c(val1,
> val2)). I don't know how to access the individual columns of that
> vector in the resulting dataframe though. How is this done correctly?
> Thanks, robert
>
>
>> agg <- aggregate(formula=df$value ~ df$quarter + df$tool,
> +     FUN=cp.cpk, lsl=1300, usl=1500)

Try this:

agg <- aggregate(value ~ quarter + tool, df,
     FUN=cp.cpk, lsl=1300, usl=1500)

do.call("data.frame", agg)

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list