Hi I am new to r I have a problem i.e to find the network of user(uID) and network of articles(faID) from a data frame called w2 like
faID uID
1 1256
1 54789
1 547821
2 3258
2 4521
2 4528
3 98745
3 1256
3 3258
3 2145
this is just a example I have over 2000 articles what I want to make a relationship between users based on articles in a data frame format e.g. ##for article one##
1258 54789
1258 547821
54789 547821
##similarly for article 2##
3258 4521
3258 4528
4528 4521
some of the other information are
dput(head(w2,)) structure(list(faID=c(1L,1L,1L,1L,1L,1L),uID=c(20909L,6661L,1591L,28065L,42783L,3113L)), .Names=c("faID","uID"),row.names=c(7L,9L,10L,12L,14L,16L),class=data.frame")
dim(w2)
[1] 364323 2
I am using the code advised by one of the volunteer
error appears at <<<>>"Error in UseMethod("regroup") :
no applicable method for 'regroup' applied to an object of class "c('integer', 'numeric')") ##
library(dplyr)
edges<-tbl_df(w2) %>%
group_by(w2$faID) %>%
do({
tmp <-combn(sort(.$user),m =2)
data.frame(a=tmp[1,],b=tmp[2,],stringsAsFactors=FALSE )
})%>%
ungroup
}
any suggestion will highly be appreciated.