I have the following code:
testset2 <- testset %>%
left_join(movie_dev, by="movieId") %>%
left_join(user_dev, by="userId") %>%
mutate(prediction = naive + ifelse(is.na(testset$movieid_dev),0,testset$movieid_dev) +ifelse(is.na(testset$userid_dev),0,testset$userid_dev))
When I explore the df, most of the prediction column is working perfectly. But it will work only for cases (movieid and userid) already known by the training_set. For all other unknown cases, prediction variable should only consider the naive object (a constant) and insert zero for unknown movieid and userids. But instead, I'm getting NAs. What should I do?