Knitr与Corrplot错误

时间:2015-01-15 18:59:48

标签: r knitr r-corrplot

我正在利用Knitr编译pdf文档,因此我正在“编织”PDF。截至昨晚,以下几行代码生成了我想从Corrplot获得的图形,没有任何问题。截至今天早上,我收到了一个错误 - 没有任何代码改变:

```{r,echo=FALSE,include=TRUE,fig.height=14,fig.width=14}
cor<-cor(data[c(3:7,11,12,14,15:51)])
require(corrplot)
corrplot(cor,type="lower",method="ellipse",tl.cex=1.2,cl.cex=1.2)
```

我收到以下错误:

Error in corrplot(cor, type = "lower", method = "ellipse", tl.cex = 1.2,  : 
unused arguments (type = "lower", method = "ellipse", tl.cex = 1.2, cl.cex = 1.2)
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> corrplot
Execution halted

当我在R中独立运行此代码而不使用knitr时,代码运行没有问题并生成我正在寻找的图形。我曾多次使用过Corrplot,之前从未遇到过这个问题。有关如何解决此问题的任何见解?

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。问题是corrplot()是不明确的。即有多个包使用函数corrplot()。据我了解,R试图选择最适合的那个。在我们的案例中,这没有达到预期效果。

只需通过编写corrplot :: corrplot()来指定您想要来自包corrplot的函数,只需告诉R你的意思是什么。

通常:packagename :: functionname()允许您明确使用哪个函数。

另见R: 2 functions with the same name in 2 different packages