I was following this Building Adjacency matrix from DF
I have this df as toy example :
lf3 = structure(list(session_id = c(1L, 1L, 1L, 2L, 3L, 5L, 5L, 6L,
6L, 7L), userId = c(1, 1, 1, 2, 2, 4, 4, 5, 5, 5), datetime =
structure(c(1457029336,
1457029337, 1457029340, 1457029596, 1457313569, 1457030783, 1457030784,
1457030918, 1457030920, 1457370365), class = c("POSIXct", "POSIXt"
), tzone = "UTC"), referer = c(22, 2, 7, 5, 23, 20, 7, 24, 18,
22), request = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 5)), .Names = c("session_id",
"userId", "datetime", "referer", "request"), row.names = c(NA,
10L), class = "data.frame")
I tried this piece of code :
lf3 %>%
mutate_at(vars(referer,request),funs(factor(., levels))) %>%
group_by(referer, request) %>%
tally() %>%
spread(request, n, drop=FALSE, fill=0)
But its giving some error
Error in mutate_impl(.data, dots) : 'match' requires vector arguments
So i tried this :
lf3 %>%
mutate_at(vars(referer,request),funs(factor(.))) %>%
group_by(referer, request) %>%
tally() %>%
spread(request, n, drop=FALSE, fill=0)
But cant make a network graph using igraph library as it gives n*n+1 dimensions 1 extra column for referer being added .so graph.adjacency() not working .How to remove that referer extra column