作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我在 R Studio 中运行下面的代码并收到此错误:
Error in UseMethod("tbl_vars") : no applicable method for 'tbl_vars' applied to an object of class "character"
我不知道如何修复它,因为没有 tbl_vars 函数!有人可以帮忙吗?
for (i in 1:ceiling(nrow(reviews)/batch)) {
row_start <- i*batch-batch+1
row_end <- ifelse(i*batch < nrow(reviews), i*batch, nrow(reviews))
print(paste("Processing row", row_start, "to row", row_end))
reviews[row_start:row_end, ] %>%
unnest_tokens(word, text) -> reviews_subset
reviews_subset$row <- 1:nrow(reviews_subset)
reviews_subset %>%
anti_join(stopwords) %>%
arrange(row) -> reviews_subset
write_feather(reviews_subset, path = paste0("reviews", i, ".txt"))
}
Ps: dplyr 已安装。还有其他已安装的软件包:pacman、feather、data.table、devtools、tidyr、tidytext、tokenizers、tibble
我用它来处理 Yelp 数据集。
非常感谢,佳美
ps2:数据集示例(经过编辑和简化以适应此处):
> dput(as.data.frame(review))
structure(list(user_id = 1:10, review_id = 11:20, business_id = 21:30,
stars = c(2L, 2L, 5L, 4L, 4L, 5L, 4L, 3L, 5L, 4L), text = c("Are you the type of person that requires being seen in an expensive, overly pretentious restaurant so that you can wear it as a status symbol? Or maybe you're a gansta who dresses like CiLo Green and wants to show the hunny's (yes, a group of them out with one man) a night on the town!",
"Today was my first visit to the new luna, and I was disappointed-- both because I really liked the old cafe luna, and because the new luna came well recommended",
"Stayed here a few months ago and still remember the great service I received.",
"I came here for a business lunch from NYC and had a VERY appetizing meal. ",
"Incredible food with great flavor. ",
"OMG, y'all, try the Apple Pie Moonshine. It. Is. Seriously. Good. Smoooooooth. The best rum that I've sampled so far: Zaya.",
"Caitlin is an amazing stylist. She took time to hear what I had to say before jumping in",
"Oh yeah! After some difficulties in securing dinner, my dad and I found ourselves at one of the billion Primanti's locations for a quick feast",
"I've been going to this studio since the beginning of January",
"The best cannoli, hands down!!"
)), .Names = c("user_id", "review_id", "business_id", "stars",
"text"), row.names = c(NA, -10L), class = "data.frame")
最佳答案
将 anti_join(stopwords)
更改为 anti_join(stop_words)
。 stopwords
可能不存在或者不是您想要的
关于R: UseMethod 错误 ("tbl_vars"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50489511/
所以我在 R Studio 中运行下面的代码并收到此错误: Error in UseMethod("tbl_vars") : no applicable method for 'tbl_vars' a
我真的需要一些有用的帮助。 我已经编写了代码,但它不起作用。但是,几乎相同的示例运行良好。 这是我得到的: Warning: Error in tbl_vars: argument "y"
我是一名优秀的程序员,十分优秀!