我已经在Linux和Windows7上安装了Sweave包和针织器,它在上运行良好,但在Linux中使用rstudio时却失败了。安装pkgs之后,我编写了一个简单的dw.Rnw,如下所示:
\documentclass{article}
\begin{document}
The regression model is as follows
<<echo=TRUE>>=
pop=read.table("pop.txt",header=TRUE)
attach(pop)
lm.sol=lm(y~year)
summary(lm.sol)
@
\end{document}
当我按下rstudio中的“编译PDF”按钮时,它会返回以下错误消息:
During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_PAPER failed, using "C"
6: Setting LC_PAPER failed, using "C"
7: Setting LC_MEASUREMENT failed, using "C"
> grDevices::pdf.options(useDingbats = FALSE); require(knitr); knit('dw.Rnw', encoding='UTF-8')
Loading required package: knitr
Warning in readLines(if (is.character(input2)) { :
cannot open file 'dw.Rnw': No such file or directory
Error in readLines(if (is.character(input2)) { :
cannot open the connection
Calls: knit -> readLines
Execution halted
看来这个函数编结有问题。但是,如果我键入
knit("dw.Rnw")
在rstudio的控制台中,它成功地生成文件dw.tex,我可以用pdflatex编译该文件,并最终生成dw.pdf。
我的针织品或rstudio怎么了?
发布于 2013-06-03 18:45:20
虽然我仍然不明白为什么,但从上面的评论来看,问题似乎来自于~/.Rprofile
(特别是setwd()
)。清理它解决了这个问题。
注意,您可能有其他启动配置文件。.Rprofile
只是一种可能。有关详细信息,请参阅?Startup
。例如,如果您在Windows上,如果C:\Program Files\R\etc\Rprofile.site
存在,您可能需要查看它。
https://stackoverflow.com/questions/16826153
复制相似问题