【发布时间】:2020-09-11 02:04:42
【问题描述】:
大家好,我对 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 latex 安装 tinytex 和 miktex 之后,但在此之前它可以完美运行以执行。 有人知道为什么吗?
【问题讨论】:
-
您好,欢迎来到 SO。请为您的问题提供一些背景信息。查看How to Ask 以获取提示。提供一些数据并创建great reproducible example 是一个好的开始。
标签: r r-markdown analytics