[datatable-help] data table question sql equivalent in data table with subqueries

Matthew Dowle mdowle at mdowle.plus.com
Sun Feb 19 23:39:30 CET 2012


Hi. Yes that can be done. Which part are you stuck on?

On Sat, 2012-02-18 at 11:38 -0500, D wrote:
> Hi Matt,
>     Is there a way to do the following in data.table:
> 
> (select ave(rating) from data x
> where x.itemid=a.itemid and x.userid!=a.userid
> and exists (select 1 from 
>     (select * from data y where y.userid=x.userid) y, 
>     (select * from data z where z.userid=a.userid) z 
>    where  y.itemid=z.itemid  
>     and y.itemid!=a.itemid
>     and abs(y.rating-z.rating)>=4 )
> ) pred_rating_disimilar
>  from data1 a')
> 
> This is based on movielens movie data of (userid, itemid, rating and timestamp).
> 
> its finding average rating on movie by all users who rated a movie differently from the current user in the row.
> 
> thanks
> Dhruv
> 
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help




More information about the datatable-help mailing list