r - could not find function "spread" -
so @ moment trying figure out how build movie recommender system movielense (https://grouplens.org/datasets/movielens/100k/). read instructions tutorial.
library(dplyr) library(recommenderlab) library(magrittr) data <- read.table("u.data", header = f, stringsasfactors = t) head(data) v1 v2 v3 v4 1 196 242 3 881250949 2 186 302 3 891717742 3 22 377 1 878887116 4 244 51 2 880606923 5 166 346 1 886397596 6 298 474 4 884182806
explanation: v1
userid, v2
itemid, v3
rating
now need log format ratingmatrix, , result this:
1 2 3 4 5 6 7 8 9 10 1 5 3 4 3 3 5 4 1 5 3 2 4 na na na na na na na na 2 3 na na na na na na na na na na 4 na na na na na na na na na na 5 4 3 na na na na na na na na 6 4 na na na na na 2 4 4 na 7 na na na 5 na na 5 5 5 4 8 na na na na na na 3 na na na 9 na na na na na 5 4 na na na 10 4 na na 4 na na 4 na 4 na
code:
temp = data %>% select(1:3) %>% spread(v2,v3) %>% select(-1) temp[1:10,1:10]
error in spread(., v2, v3) : not find function "spread"
try replacing library(dplyr)
library(tidyverse)
. spread
function lives in tidyr
package part of tidyverse
along dplyr
.
Comments
Post a Comment