[R] Table
Val
valkremk at gmail.com
Thu Feb 11 04:10:44 CET 2016
Hi all,
I want create a frequency table using this :
xc1<- sample(c(1:10), 100, replace = TRUE)
xc2<- sample(c(0,1), 100, replace = TRUE)
xc3<- cbind(xc1,xc2)
tab1<- xc3[,list( d1=sum(xc2==0), d2=sum(xc2==1)),by=xc1]
but not working.
Error in `[.data.frame`(xc3, , list(d1 = sum(xc2 == 1), d2 = sum(xc2 == :
unused argument (by = xc1)
any idea?
I want the result like this
xc1 d1 d2
1 11 5
2 5 4
3 5 4
4 2 5
5 2 7
6 7 4
7 9 5
8 2 6
9 5 4
10 3 5
[[alternative HTML version deleted]]
More information about the R-help
mailing list