编织LaTeX文件时出错:找不到“as”功能

时间:2022-07-29 17:05:16

I am trying to knit a chunk embedded in a latex file with extension Rnw.

我正在尝试编织嵌入在扩展名为Rnw的乳胶文件中的块。

library(ggplot2)
library(flexclust)
library(arules)

data(Groceries)

Gr <- Groceries[, itemFrequency(Groceries) > 0.02]
grc <- as(Gr, "matrix")

I get this error:

我收到此错误:

#Error in as(Gr, "matrix") could not find function "as"

The same commands work perfectly well in R

相同的命令在R中运行得非常好

Any ideas?

1 个解决方案

#1


0  

When in doubt, try to upgrade your software packages. If you are using a recent version of R (>= 3.5.0), you should not need to library(methods), because it will be loaded (attached) by default. This problem (Rscript does not load methods) has existed in base R for many years until this year and surprised/confused many users. If you have to use an old version of R, you will need library(methods) explicitly.

如有疑问,请尝试升级软件包。如果您使用的是最新版本的R(> = 3.5.0),则不需要库(方法),因为默认情况下它将被加载(附加)。这个问题(Rscript不加载方法)已存在于基础R多年,直到今年,并使许多用户感到惊讶/困惑。如果必须使用旧版本的R,则需要显式地使用库(方法)。

#1


0  

When in doubt, try to upgrade your software packages. If you are using a recent version of R (>= 3.5.0), you should not need to library(methods), because it will be loaded (attached) by default. This problem (Rscript does not load methods) has existed in base R for many years until this year and surprised/confused many users. If you have to use an old version of R, you will need library(methods) explicitly.

如有疑问,请尝试升级软件包。如果您使用的是最新版本的R(> = 3.5.0),则不需要库(方法),因为默认情况下它将被加载(附加)。这个问题(Rscript不加载方法)已存在于基础R多年,直到今年,并使许多用户感到惊讶/困惑。如果必须使用旧版本的R,则需要显式地使用库(方法)。