mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Adding experimental recommendations in R.
This commit is contained in:
parent
c3d7f0670d
commit
d1733cda21
1 changed files with 18 additions and 0 deletions
18
r/recs.r
Normal file
18
r/recs.r
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
library(RPostgreSQL)
|
||||||
|
drv = dbDriver("PostgreSQL")
|
||||||
|
db <- dbConnect(drv, dbname="newsblur", user="newsblur")
|
||||||
|
query = "SELECT user_id, feed_id, is_trained FROM reader_usersubscription"
|
||||||
|
data = dbGetQuery(db, query)
|
||||||
|
|
||||||
|
common_users_by_id <- function(feed1, feed2) {
|
||||||
|
subs1 <- subset(data, feed_id=feed1)
|
||||||
|
subs2 <- subset(data, feed_id=feed2)
|
||||||
|
subs_sameset <- intersect(subs1['user_id'],
|
||||||
|
subs2['user_id'])
|
||||||
|
if (length(subs_sameset) > 0) {
|
||||||
|
NA
|
||||||
|
} else {
|
||||||
|
subs_sameset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue