Skip to content
Back to formatted view

Raw Message

Message-ID: <CAP01uRkNJK4xLcGaYcd4tYmYAPK=OiC3hAOQRBODn5Es7v21Gg@mail.gmail.com>
Date: 2012-05-09T14:10:34Z
From: Gabor Grothendieck
Subject: How to deal with a dataframe within a dataframe?
In-Reply-To: <CAMXbmUTQAuT_1JNtVw_MWoaaDFeg+krj2ytTfBz1-ffabt68Hw@mail.gmail.com>

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