Re: [R] Equivalent of Excel pivot tables in R

2008-04-26 Thread Simon Blomberg
PROTECTED] on behalf of ppaarrkk Sent: Sat 26/04/2008 7:54 AM To: r-help@r-project.org Subject: [R] Equivalent of Excel pivot tables in R Can somebody tell me how to do the equivalent of a pivot table in R ? For example, if I have : var1var2 var3 a x10 b y20 a

Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Jorge Ivan Velez
Hi, I forgot the first part (I'm sorry): table(var1,var2) var2 var1 x y z a 1 0 2 b 0 1 2 HTH, Jorge On Fri, Apr 25, 2008 at 7:25 PM, Jorge Ivan Velez <[EMAIL PROTECTED]> wrote: > > Hi, > > Try this: > > x="var1var2 var3 > a x10 > b y20 > a

Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Henrique Dallazuanna
Try: with(x, tapply(var3, list(var1, var2), length)) with(x, tapply(var3, list(var1, var2), sum)) Or with xtabs xtabs(as.logical(var3) ~ var1 + var2, data = x) xtabs(var3 ~ var1 + var2, data = x) On 4/25/08, ppaarrkk <[EMAIL PROTECTED]> wrote: > > > Can somebody tell me how to do the equiv

Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Jim Porzak
See Hadley's reshape package http://had.co.nz/reshape/ and on CRAN. On Fri, Apr 25, 2008 at 2:54 PM, ppaarrkk <[EMAIL PROTECTED]> wrote: > > Can somebody tell me how to do the equivalent of a pivot table in R ? > > > For example, if I have : > > var1var2 var3 > a x10 > b

Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Jorge Ivan Velez
Hi, Try this: x="var1var2 var3 a x10 b y20 a z10 b z20 a z10 b z20" yourdata=read.table(textConnection(x),header=TRUE) attach(yourdata) res=tapply(var3,yourdata[,-3],sum) # With tapply! res[is

[R] Equivalent of Excel pivot tables in R

2008-04-25 Thread ppaarrkk
Can somebody tell me how to do the equivalent of a pivot table in R ? For example, if I have : var1var2 var3 a x10 b y20 a z10 b z20 a z10 b z20 I could have : x y z a