从共享驱动器呈现 rmarkdown 时出现问题

Problems rendering rmarkdown from shared drive

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

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

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

rmarkdown::render("//cor.local/subfolders/Martin/aNewRMD.RMD")

但这成功了:

rmarkdown::render("C:/Users/Martin/Documents/aNewRMD.RMD")

(我只是使用 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.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

我相信 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://'.

你用 "//cor.local/subfolders/Martin/aNewRMD.RMD" 做的是告诉它向名为 cor.local 的主机(以某种方式进行身份验证)讲一个 windows 文件共享协议(smb、cifs 等),并且导航到相应的子目录。

我的建议:让 windows 提前处理基本身份验证,"mount" 这样本地计算机上的每个应用程序都会将其视为 "local" 但安装它到一个盘符:

C:\Users\AM4337> net use /user:yourdomain\youruser g: \cor.local\subfolders

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

R> rmarkdown::render("G:/Martin/aNewRMD.RMD")

在组织升级到 windows 10 后,多个用户尝试 运行 现有 R 进程时遇到了同样的问题:'Error: pandoc document conversion failed with error 1'。

将项目文件夹更改为 RStudio 项目解决了这个问题。 RStudio 项目使用每个用户的本地路径设置自己的工作目录,因此将网络路径替换为本地字母路径。感谢 @r2evans 解释问题并启用此解决方法。

(为单独的回答道歉,我没有资格评论@r2evans 的回答。)