for a data frame as follow
id<-c(1,1,2,3,3,2)
p<-c(10,0,22,34,0,0)
df<-data.frame(id,p)
I need a summary table like
id p
1 10
2 22
3 34
which is actually aggregated summation of p for each id.
can I get this with ‘dcast’?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why do you need
dcast? Tryaggregatein base R:You can also trick
dcastas below. Your data is not quite in the expected “molten” form fordcast: