从共享驱动器呈现 rmarkdown 的问题

Adr*_*tin 3 r pandoc knitr r-markdown

当我的 RMD 文件位于共享驱动器上时,我无法呈现降价文件。我使用的是 rmarkdown 版本 1.12、R 版本 3.5.3、64 位 Windows 10、pandoc 2.7.1。

我无法呈现为 html、pdf 或 word 文档。

这失败了(我的文件夹路径中没有空格或标点符号):

rmarkdown::render("//cor.local/subfolders/Martin/aNewRMD.RMD")
Run Code Online (Sandbox Code Playgroud)

但这成功了:

rmarkdown::render("C:/Users/Martin/Documents/aNewRMD.RMD")
Run Code Online (Sandbox Code Playgroud)

(我只是使用 RStudio 打开的默认新 .RMD 文件)。

错误信息:

processing file: aNewRMD.RMD
  |.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: cars
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: pressure (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code


output file: aNewRMD.knit.md

"C:/Pandoc/pandoc" +RTS -K512m -RTS aNewRMD.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output aNewRMD.html --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\Martin\Documents\R\win-library\3.5\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\Martin\AppData\Local\Temp\RtmpGoqMWG\rmarkdown-str421411883120.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 
pandoc.exe: aNewRMD.utf8.md: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Run Code Online (Sandbox Code Playgroud)

r2e*_*ans 5

我相信 R 不知道(还)如何为网络共享说出任意 URI。虽然我猜测某些功能(和其他包)可能支持其他方案,但download.file帮助页面说

 The function 'download.file' can be used to download a single file
 as described by 'url' from the internet and store it in
 'destfile'.  The 'url' must start with a scheme such as 'http://',
 'https://', 'ftp://' or 'file://'.
Run Code Online (Sandbox Code Playgroud)

您正在做的"//cor.local/subfolders/Martin/aNewRMD.RMD"是告诉它与名为cor.local(以某种方式进行身份验证)的主机交谈 Windows 文件共享协议(smb、cifs 等)并导航到相应的子目录。

我的建议:让 Windows 提前处理基本身份验证,并“挂载”它,以便本地计算机上的每个应用程序都将其视为“本地”,但将其挂载到驱动器号:

C:\Users\AM4337> net use /user:yourdomain\youruser g: \\cor.local\subfolders
Run Code Online (Sandbox Code Playgroud)

(它应该询问您的密码),然后在本地使用/使用它

 The function 'download.file' can be used to download a single file
 as described by 'url' from the internet and store it in
 'destfile'.  The 'url' must start with a scheme such as 'http://',
 'https://', 'ftp://' or 'file://'.
Run Code Online (Sandbox Code Playgroud)

  • @Ben,我不知道如何扩展这个答案:(1)建议生成本地出现的驱动器号`g:`所需的命令行相对清晰;(2) 我对你的情况一无所知。这是一种通用解决方案,为一个网络位置提供一个驱动器号;它适用于需要保存到该特定网络位置(或其子目录)的任何 Rmd 文件。每次登录时很可能需要重做,但有办法使其准永久/重复。 (2认同)