I am getting the following error when checking my R package
在检查我的R包时,我得到以下错误。
> Error: could not find function "locdata"
> Execution halted
> when running code in ‘DFSurvey.Rnw’
> ...
>
> > opts_chunk$set(cache = TRUE, fig.path = "DFSurveyImages/", dev = "pdf")
>
> When sourcing ‘DFSurvey.R’:
> Error: object 'opts_chunk' not found
> Execution halted
Yihui Xie (knitr developer) said that was because in RStudio, knitr was not set as the method for weaving .Rnw files, https://groups.google.com/forum/?fromgroups#!topic/knitr/9672CBbc8CM. I have knitr set in both the tools and build options, in the R package DESCRIPTION file I have:
Yihui Xie (knitr开发人员)说,这是因为在RStudio中,knitr不作为编织. rnw文件、https://groups.google.com/forum/?fromgroups#!topic/knitr/9672CBbc8CM的方法。我在工具和构建选项中都设置了knitr,在我拥有的R包描述文件中:
VignetteBuilder: knitr
Suggests: knitr
and in the vignette I have:
在小插图里我有:
%\VignetteEngine{knitr}
%\VignetteDepends{knitr,xtable,TSP}
When I use compile the pdf in RStudio or use knit("KNITR.Rnw"), it compiles correctly. When I check the package, I get the above errors for each vignette. I even put
当我在RStudio中使用编译或使用编织(“KNITR.Rnw”)时,它会正确地编译。当我检查包的时候,我得到了上面每个小细节的错误。我甚至把
require(knitr)
before my opts_chunk$set statement. That did not help. I have also run the check from the command line and gotten the same error. Thank you for any help.
在我opts_chunk设置语句美元。没有帮助。我还从命令行运行了检查,并得到了相同的错误。谢谢你的帮助。
Knitr is a useful package. I run long simulations in vignettes, and the cache makes it possible to correct errors without running the simulations over each time. It does not have the problem of trying to find the Sweave.sty file either.
Knitr是一个有用的包。我在vignettes中运行了长时间的模拟,并且缓存使得在每次都不运行模拟的情况下可以纠正错误。它没有试图找到那个瑞典人的问题。住在猪圈里的文件。
Here is my sessionInfo()
这是我sessionInfo()
> R version 3.0.0 (2013-04-03)
> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] tcltk grid stats graphics grDevices utils datasets methods
> [9] base
>
> other attached packages:
> [1] DualFrame_0.5 xtable_1.7-1 TSP_1.0-7
> [4] maptools_0.8-23 lattice_0.20-15 foreign_0.8-53
> [7] spsurvey_2.5 sp_1.0-9 stringr_0.6.2
> [10] sqldf_0.4-6.4 RSQLite.extfuns_0.0.1 chron_2.3-43
> [13] gsubfn_0.6-5 proto_0.3-10 RSQLite_0.11.3
> [16] DBI_0.2-7 knitr_1.2 gpclib_1.5-5
>
> loaded via a namespace (and not attached):
> [1] deldir_0.0-22 digest_0.6.3 evaluate_0.4.3 formatR_0.7 MASS_7.3-26
> [6] rgeos_0.2-17 tools_3.0.0
3 个解决方案
#1
48
put library(knitr)
before this opts_chunk$set(cache = TRUE, fig.path = "DFSurveyImages/", dev = "pdf")
将库(knitr)放在opts_chunk$set之前(缓存= TRUE, fig.path = "DFSurveyImages/", dev = "pdf")
#2
-1
For a knitr vignette that you can compile using knit() or with the "Compile PDF" button in RStudio, but that gets an
对于knitr vignette,您可以使用编织()或在RStudio中使用“compile PDF”按钮进行编译,但这将得到一个。
Error: object 'opts_chunk' not found Execution halted
错误:object 'opts_chunk'未发现执行停止。
error when checking or building the package, the package check code is not recognizing that your .Rnw file should be knit
ed and not Sweave
ed. Check that you have the following:
在检查或构建包时出现错误,包检查代码不认识到您的. rnw文件应该是应该的,而不是Sweaveed。检查你是否有以下内容:
-
The vignettes are in the vignette directory, if you have R 3.0.0 or higher (this was the solution to this post), cran.r-project.org/doc/manuals/r-devel/R-exts.html#Non_002dSweave-vignettes
在vignette目录中,如果您有r3.0.0或更高版本(这是本文的解决方案),cran.r-project.org/doc/manuals/r-devel/R-exts.html#Non_002dSweave-vignettes。
-
Include
%\VignetteEngine{knitr::knitr}
in the vignette metadata, yihui.name/knitr/demo/vignette/包括%\VignetteEngine{knitr::knitr}在vignette元数据,yihui.name/knitr/demo/vignette/。
-
Specify
VignetteBuilder: knitr
in the package DESCRIPTION file, and在包描述文件中指定VignetteBuilder: knitr。
-
Add
Suggests: knitr
in DESCRIPTION if knitr is needed only for vignettes添加建议:knitr在描述中,如果knitr只需要一个小片断。
If that does not work add a require(knitr) statement before you set your global options in opts_chunk()
, as Ben Bolker, Yuhui and Tyler Rinker suggested.
如果这不能在您在opts_chunk()中设置全局选项之前添加一个require(knitr)语句,就像Ben Bolker、Yuhui和Tyler Rinker所建议的那样。
If in RStudio: In BOTH the Build configuration and Tool options, set the Sweave option to knitr, www.rstudio.com/ide/docs/authoring/rnw_weave
如果在RStudio中:在构建配置和工具选项中,将Sweave选项设置为knitr, www.rstudio.com/ide/docs/authoring/rnw_weave。
#3
-1
Changing the Sweave option to knitr in the Tools options worked for me.
将Sweave选项改为knitr在工具选项中为我工作。
#1
48
put library(knitr)
before this opts_chunk$set(cache = TRUE, fig.path = "DFSurveyImages/", dev = "pdf")
将库(knitr)放在opts_chunk$set之前(缓存= TRUE, fig.path = "DFSurveyImages/", dev = "pdf")
#2
-1
For a knitr vignette that you can compile using knit() or with the "Compile PDF" button in RStudio, but that gets an
对于knitr vignette,您可以使用编织()或在RStudio中使用“compile PDF”按钮进行编译,但这将得到一个。
Error: object 'opts_chunk' not found Execution halted
错误:object 'opts_chunk'未发现执行停止。
error when checking or building the package, the package check code is not recognizing that your .Rnw file should be knit
ed and not Sweave
ed. Check that you have the following:
在检查或构建包时出现错误,包检查代码不认识到您的. rnw文件应该是应该的,而不是Sweaveed。检查你是否有以下内容:
-
The vignettes are in the vignette directory, if you have R 3.0.0 or higher (this was the solution to this post), cran.r-project.org/doc/manuals/r-devel/R-exts.html#Non_002dSweave-vignettes
在vignette目录中,如果您有r3.0.0或更高版本(这是本文的解决方案),cran.r-project.org/doc/manuals/r-devel/R-exts.html#Non_002dSweave-vignettes。
-
Include
%\VignetteEngine{knitr::knitr}
in the vignette metadata, yihui.name/knitr/demo/vignette/包括%\VignetteEngine{knitr::knitr}在vignette元数据,yihui.name/knitr/demo/vignette/。
-
Specify
VignetteBuilder: knitr
in the package DESCRIPTION file, and在包描述文件中指定VignetteBuilder: knitr。
-
Add
Suggests: knitr
in DESCRIPTION if knitr is needed only for vignettes添加建议:knitr在描述中,如果knitr只需要一个小片断。
If that does not work add a require(knitr) statement before you set your global options in opts_chunk()
, as Ben Bolker, Yuhui and Tyler Rinker suggested.
如果这不能在您在opts_chunk()中设置全局选项之前添加一个require(knitr)语句,就像Ben Bolker、Yuhui和Tyler Rinker所建议的那样。
If in RStudio: In BOTH the Build configuration and Tool options, set the Sweave option to knitr, www.rstudio.com/ide/docs/authoring/rnw_weave
如果在RStudio中:在构建配置和工具选项中,将Sweave选项设置为knitr, www.rstudio.com/ide/docs/authoring/rnw_weave。
#3
-1
Changing the Sweave option to knitr in the Tools options worked for me.
将Sweave选项改为knitr在工具选项中为我工作。