为什么Rmarkdown不会覆盖以前无法覆盖的打开的html文件或文件?

时间:2016-05-19 14:05:05

标签: html r rstudio r-markdown

RMarkdown似乎不再覆盖打开的html文件。我已经在几台不同的机器上尝试了这个,并且有很多不同的文件。就像去年夏天一样,我能够编写html文档,渲染新版本,只需刷新页面即可查看更新。

最重要的是,一旦你试图覆盖打开的html文件,即使在关闭它之后,在删除文件之前不允许进一步更新。

任何想法可能导致这种或可能的解决方案?

 library(rmarkdown)

# set up to allow the use of a different directory
directory <- getwd()
write(' ## Testing what comes out ', file = paste(directory, "nonsense.rmd", sep=""))

render(paste(directory, "nonsense.rmd", sep=""), output_format="html_document", 
       output_file="openPageBeforeRe-runningRender.html", output_dir = directory)

# open url
browseURL(paste(directory, "openPageBeforeRe-runningRender.html", sep=""))

# re-run render with document open
render(paste(directory, "nonsense.rmd", sep=""), output_format="html_document", 
       output_file="openPageBeforeRe-runningRender.html", output_dir = directory)

# close document and re-run render
render(paste(directory, "nonsense.rmd", sep=""), output_format="html_document", 
       output_file="openPageBeforeRe-runningRender.html", output_dir = directory)

# even with the document now closed it appears to be permanently unable to write updates to the html file

# once you remove the file you're allowed to write it again
file.remove(paste(directory, "openPageBeforeRe-runningRender.html", sep=""))
render(paste(directory, "nonsense.rmd", sep=""), output_format="html_document", 
       output_file="openPageBeforeRe-runningRender.html", output_dir = directory)

部分错误消息

openFile: permission denied (Permission denied)
Error: pandoc document conversion failed with error 1

1 个答案:

答案 0 :(得分:0)

原来是与权限有关。它并不完全确定,但可能是因为我有读取和写入权限,但我没有删除权限,我现在这样做,问题已经解决了。