我正在尝试编写嵌入在扩展名为Rnw的乳胶文件中的块。
library(ggplot2)
library(flexclust)
library(arules)
data(Groceries)
Gr <- Groceries[, itemFrequency(Groceries) > 0.02]
grc <- as(Gr, "matrix")
我收到此错误:
#Error in as(Gr, "matrix") could not find function "as"
相同的命令在R
中运行良好有什么想法吗?
答案 0 :(得分:0)
When in doubt, try to upgrade your software packages.如果您使用的是最新版本的R(&gt; = 3.5.0),则不需要library(methods)
,因为默认情况下它将被加载(附加)。此问题(Rscript
直到今年才加载方法)has existed in base R for many years,并使许多用户感到惊讶/困惑。如果您必须使用旧版本的R,则需要library(methods)
显式。