Skip to content
Back to formatted view

Raw Message

Message-ID: <3A080905-ABB3-4F6A-BA85-844D6724B084@comcast.net>
Date: 2012-11-08T21:03:56Z
From: David Winsemius
Subject: Regrouping dataframe
In-Reply-To: <1352397094322-4648927.post@n4.nabble.com>

On Nov 8, 2012, at 9:51 AM, Geophagus wrote:

> Hi @ all,
> I hope for some help of you.
> I have a dataframe and I want to regroup it.
> examp4.csv <http://r.789695.n4.nabble.com/file/n4648927/examp4.csv>  

Sigh. Please expalin why you posted a link to a "csv file" that had no commas.

> 
> I need the arguments of "VAL" as table heads and the "TYPE " only in
> individual expression.
> The result should look like in the example pic.
> 
> exp4.png <http://r.789695.n4.nabble.com/file/n4648927/exp4.png>  
> 
> I think reshape can do it?

Perhaps, but since you only have one value per cross-category, why not:

xtabs(AMOUNT ~ TYPE+VAL, data=t1)

OR:

tapply(t1$AMOUNT, list(t1$TYPE, t1$VAL), c)


-- 

David Winsemius, MD
Alameda, CA, USA