Dear all,

I'm puzzled by the following example inspired by a recent question on R-help,


cc <- textConnection("user_id  website          time
20        google            0930
21        yahoo            0935
20        facebook        1000
25        facebook        1015
61        google            0940")

d <- read.table(cc, head=T) ; close(cc)

table(d$user_id) # count the occurrences

# now I'd like to include these results in the original data.frame,

ddply(d, .(website), transform, count = table(user_id)) # why two new columns?

I just can't understand how this is different from,

ddply(d, .(website), transform, count = sum(user_id))


Many thanks,

baptiste

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to