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> 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? Thanks GeO -- View this message in context: http://r.789695.n4.nabble.com/Regrouping-dataframe-tp4648927.html Sent from the R help mailing list archive at Nabble.com.
Thank you very much! It works ! Best greetings GeO -- View this message in context: http://r.789695.n4.nabble.com/Regrouping-dataframe-tp4648927p4648956.html Sent from the R help mailing list archive at 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
Hi, No problem. Another method will be: library(reshape2) dcast(dat1,TYPE~VAL,value.var="AMOUNT") #??? TYPE BB BE? BK? BW BZ HH HR MN? MT? NK? RR SL SM SN SZ UU #1 WASTE1 82 19 254 167 14 33 93 48 144 359 112 27 62 59 86 51 #2 WASTE2 11? 2? 60? 46 NA 13 54? 6? 48 159? 19? 2 16 16 59? 9 #3 WASTE3 15 16? 33? 23? 5? 3 15? 4? 27? 72?? 5? 9? 6 16 20 10 A.K. ----- Original Message ----- From: Geophagus <fh at retposto.net> To: r-help at r-project.org Cc: Sent: Thursday, November 8, 2012 3:04 PM Subject: Re: [R] Regrouping dataframe Thank you very much! It works ! Best greetings GeO -- View this message in context: http://r.789695.n4.nabble.com/Regrouping-dataframe-tp4648927p4648956.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.