plyr and table question
On Fri, Apr 3, 2009 at 8:43 AM, baptiste auguie <ba208 at exeter.ac.uk> wrote:
That makes sense, so I can do something like,
count <- function(x){
? ? ? ?as.integer(unclass(table(x)))
}
count(d$user_id)
ddply(d, .(user_id), transform, count = count(user_id))
?user_id ?website time count 1 ? ? ?20 ? google ?930 ? ? 2 2 ? ? ?20 facebook 1000 ? ? 2 3 ? ? ?21 ? ?yahoo ?935 ? ? 1 4 ? ? ?25 facebook 1015 ? ? 1 5 ? ? ?61 ? google ?940 ? ? 1
Have I missed a built-in function to obtain this result?
ddply(d, .(user_id), transform, count = nrow) ? Hadley