0

Hye everyone, I have problem with R Markdown, I tried to compiled below R Code into pdf file but the problem is it has some issue with omitting NA values, I use tinytex by the way.

R-version: 4.0.0

library(tidyr)
library(dplyr)
dl <- tempfile()
download.file("http://files.grouplens.org/datasets/movielens/ml-10m.zip", dl)
ratings <- read.table(text = gsub("::", "\t", readLines(unzip(dl, "ml-10M100K/ratings.dat"))),
                      col.names = c("userId", "movieId", "rating", "timestamp"))
movies <- str_split_fixed(readLines(unzip(dl, "ml-10M100K/movies.dat")), "\\::", 3)
colnames(movies) <- c("movieId", "title", "genres")
movies <- as.data.frame(movies) %>% mutate(movieId = as.numeric(levels(movieId))[movieId],
                                           title = as.character(title),
                                           genres = as.character(genres))
movielens <- left_join(ratings, movies, by = "movieId")

edx <- movielens[-test_index,]
edx <- edx %>% mutate(year = as.numeric(str_sub(title,-5,-2)))

split_edx  <- edx  %>% separate_rows(genres, sep = "\\|")

genres_popularity <- split_edx %>%
  na.omit() %>% # omit missing values
  select(movieId, year, genres) %>% # select columns we are interested in
  mutate(genres = as.factor(genres)) %>% # turn genres in factors
  group_by(year, genres) %>% # group data by year and genre
  summarise(number = n()) %>% # count
  complete(year = full_seq(year, 1), genres, fill = list(number = 0)) # add missing years/genres

I got this error:

Error in if (any(((x - rng[1])%%period > tol) & (period - (x - rng[1])%%period > :
missing value where TRUE/FALSE needed
Calls: ... dots_cols -> eval_tidy -> full_seq -> full_seq.numeric Execution halted

This happen actually after I installed tinytex and miktex for r markdon latex, but before this it runs perfectly for execution. Does anybody know why?

pseudox
  • 1
  • 2
  • Hi there and welcome to SO. Please give us some context to your question. Take a look at [How to Ask](https://stackoverflow.com/help/how-to-ask) for hints. It's a good start to give some data and make a [great reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Martin Gal May 24 '20 at 13:11

1 Answers1

0

When I do rerun your code and I get to the

edx  %>% separate_rows(genres, sep = "\\|")

My computer takes forever to progress the data, I will have to try later when I am home on my larger machine, I will try seeing I can help you

Daniel_j_iii
  • 3,041
  • 2
  • 11
  • 27
  • this error actually u have to update your R and load library dplyr and tidyr. I am so sorry i missed that. – pseudox May 26 '20 at 16:17
  • cool, i guess maybe next time adding "sessionInfo()" to your question would let others see your dplyr versions, but glad you got it fixed – Daniel_j_iii May 26 '20 at 16:33