R-markdown错误在某些段落上缺少值的编译

问题描述 投票:0回答:1

[大家好,我对R Markdown有疑问,我尝试将以下R代码编译为pdf文件,但问题是它在忽略NA值方面存在一些问题,顺便说一下,我使用tinytex。

R版本: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

我收到此错误:

如果if(any(((((x-rng [1])%% period> tol)&(period-(x-rng [1])%% period>需要TRUE / FALSE的缺失值调用:... dots_cols-> eval_tidy-> full_seq-> full_seq.numeric执行中止

这实际上是在我为r markdon乳胶安装了tinytex和miktex之后,但在此之前它可以完美地执行。有人知道为什么吗?

r r-markdown analytics
1个回答
0
投票

[当我重新运行您的代码后,我进入了

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

我的计算机需要花费大量的时间来处理数据,当我在家中使用较大的计算机时,我将不得不稍后再尝试,如果能为您提供帮助,我将尝试尝试

© www.soinside.com 2019 - 2024. All rights reserved.