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?