I have a dataframe x like this
Id Group Var1
001 A yes
002 A no
003 A yes
004 B no
005 B yes
006 C no
I want to create a data frame like this
Group yes no
A 2 1
B 1 1
C 0 1
The function .aggregate works well
aggregate(x$Var1 ~ x$Group,FUN=summary)
but I am not able to create a dataframe with the results.
If I try using .ddply
ddply(x,"Group",function(x) summary(x$Var1))
I obtain the error: Results do not have equal lengths.
What am I doing wrong?
Thanks.