Re: [R] help with mysql and R: partitioning by quintile

From: Phil Spector <spector_at_stat.berkeley.edu>
Date: Sun, 08 May 2011 15:52:19 -0700 (PDT)

One way to get the ratings would be to use the ave() function:

rating = ave(x$freq,x$track,

              FUN=function(x)cut(x,quantile(x,(0:5)/5),include.lowest=TRUE))

On Sun, 8 May 2011, gj wrote:

> Hi,
>
> I have a mysql table with fields userid,track,frequency e.g
> u1,1,10
> u1,2,100
> u1,3,110
> u1,4,200
> u1,5,120
> u1,6,130
> .
> u2,1,23
> .
> .
> where "frequency" is the number of times a music track is played by a
> "userid"
>
> I need to turn my 'frequency' table into a rating table (it's for a
> recommender system). So, for each user, I need to categorise the frequency
> of tracks played by quintile so that each particular track can have 5
> ratings (1-5), with the ratings allocated as follows: inter-quintile range
> 100-80% = rating 5, inter-quintile range 80-60% = rating 4,
> ..., inter-quintile range 20-0% = rating 1)
>
> Hence, I need to create a table with fields userid,track,rating:
> u1,1,1
> u1,2, 3
> ...
>
> Can anybody help me to do this with R?
>
> Regards
> Gawesh
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>



R-help_at_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. Received on Sun 08 May 2011 - 22:55:47 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 May 2011 - 23:40:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive