gpt4 book ai didi

r - 为 'texi2dvi' 设置 'R CMD Rd2pdf'

转载 作者:行者123 更新时间:2023-12-04 16:48:20 24 4
gpt4 key购买 nike

我的 texi2dvi 显然在 R CMD Rd2pdf 不期望的地方。我的在 /usr/local/bin/texi2dvi,正在 /usr/local/opt/texinfo/bin/texi2dvi 中查找:

[KenMacBook:~/git] % \R CMD Rd2pdf missing
Hmm ... looks like a package
Converting Rd files to LaTeX
Creating pdf output from LaTeX ...
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:

Error in running tools::texi2pdf()

我可以通过运行 R_TEXI2DVICMD=/usr/local/bin/texi2dvi R CMD Rd2pdf 来解决这个问题,然后正确构建文档。

我想将该设置放入我的 .Rprofile 中,这样 RStudio(它不会读取我的 .zshrc)和其他随机 R session 将查看设置。但以下两项似乎对我的 .Rprofile 没有任何影响:

Sys.setenv(R_TEXI2DVICMD='/usr/local/bin/texi2dvi')
options(texi2dvi='/usr/local/bin/texi2dvi')

我猜 .Rprofile 不会被 R CMD 命令读取,对吗?有合适的地方放置我的设置吗?

更新:

由于德克怀疑我对 .RProfile 影响 R CMD Rd2pdf 的怀疑:-),这是我的证据:

[KenMacBook:~/git] % tail -n2 ~/.Rprofile
Sys.setenv(TEXI2DVI='/no/where')
cat("End of RProfile\n")

[KenMacBook:~/git] % Rscript -e '2+2'
End of RProfile
[1] 4

[KenMacBook:~/git] % R CMD Rd2pdf missing
Hmm ... looks like a package
Converting Rd files to LaTeX
Creating pdf output from LaTeX ...
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: /usr/local/opt/texinfo/bin/texi2dvi: No such file or directory
Output:

Error in running tools::texi2pdf()

请注意,在正常的 R session 中会遵守文件的设置,但设置 TEXI2DVI 在这里无效。

最佳答案

这似乎是错误的,因为 /usr/local/bin/texi2dvi 应该在 $PATH 中。我有

edd@max:~$ grep texi2dvi /etc/R/Renviron
## used for options("texi2dvi")
R_TEXI2DVICMD=${R_TEXI2DVICMD-${TEXI2DVI-'/usr/bin/texi2dvi'}}
edd@max:~$

请注意,如果您想设置TEXI2DVI 环境变量,您可能必须在启动 R 之前开始 -- 想想~/.bash_profile

这里是一个明确设置TEXI2DVI的例子:

edd@max:/tmp$ TEXI2DVI=/no/where R CMD Rd2pdf Rcpp-package.Rd 
Converting Rd files to LaTeX ...
Rcpp-package.Rd
Creating pdf output from LaTeX ...
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: 1: /no/where: not found
Output:

Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
Running 'texi2dvi' on 'Rd2.tex' failed.
Messages:
sh: 1: /no/where: not found
Output:

Error in running tools::texi2pdf()
edd@max:/tmp$

如您所见,它受到尊重。

编辑:另外,我们不要忘记 RenvironRenviron.site,因此您有很多选择,所以请设置他的。

编辑 2:您似乎怀疑 ~/.Rprofile:

edd@max:~$ tail -1 .Rprofile
cat("End of .Rprofile\n")
edd@max:~$ Rscript -e '2+2'
End of .Rprofile
[1] 4
edd@max:~$

关于r - 为 'texi2dvi' 设置 'R CMD Rd2pdf',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34007029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com