On Fri, Apr 3, 2009 at 8:43 AM, baptiste auguie <ba...@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

-- 
http://had.co.nz/

______________________________________________
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