See also the reshape package.
Cheers,
Simon.
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
Faculty of Biological and Chemical Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
Pol
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
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
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
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
5 matches
Mail list logo