轻松记录您
灵感和创意

你一定见过Rmarkdownd的这个错误

找到了文章中文帖子

Rstudio中的配置:工具-全局选项-常规,设置设置的编码格式为UTF-8(默认文本编码:UTF-8)。当然,如果是替换的[Ask]状态,Rstudio弹框框出来的当时再选UTF-8也是可以的。

博客园地址:https://www.cnblogs.com/loca/p/4541679.html

大概的意思就是设置utf-8为替换输出。

我进行修改后却出现来另一个错误

Error: pandoc document conversion failed with error 11

Google后发现文章有用的帖子

https://github.com/rstudio/rstudio/issues/3661

有更换R收徒弟弟哦版本的,有更换输出方式的,但是最终唯有这个小脚本最适合并解决问题。运行之后完美解决问题,这里直接放出源代码。这里安装pandoc 2.7.1。

如果有类似的问题,在R中运行下面的代码并重启。

# Download pandoc 2.7.1 built with ghc-8.6.4, and instruct

# RStudio + rMarkdown to use it.

path = getwd()

path

local({

# The directory where Pandoc will be extracted. Feel free

# to adjust this path as appropriate.

dir <- path

# The version of Pandoc to be installed.

version <- “2.7.1”

# Create and move to the requested directory.

dir.create(dir, showWarnings = FALSE, recursive = TRUE)

owd <- setwd(dir)

on.exit(setwd(owd), add = TRUE)

# Construct path to pandoc.

root <- “https://s3.amazonaws.com/rstudio-buildtools”

suffix <- sprintf(“pandoc-%s-windows-x86_64.zip”, version)

url <- file.path(root, “pandoc-rstudio”, version, suffix)

# Download and extract pandoc.

file <- basename(url)

utils::download.file(url, destfile = file)

utils::unzip(file)

unlink(file)

# Write .Renviron to update the version of Pandoc used.

entry <- paste(“RSTUDIO_PANDOC”, shQuote(path.expand(dir)), sep = ” = “)

contents <- if (file.exists(“~/.Renviron”)) readLines(“~/.Renviron”)

filtered <- grep(“^RSTUDIO_PANDOC”, contents, value = TRUE, invert = TRUE)

amended <- union(filtered, entry)

writeLines(amended, “~/.Renviron”)

# Report change to the user.

writeLines(“Updated .Renviron:\n”)

writeLines(amended)

writeLines(“\nPlease restart RStudio for these changes to take effect.”)

})

未经允许不得转载:坚果之云 Markdown » 你一定见过Rmarkdownd的这个错误
分享到: 更多 (0)

坚果云Markdown轻松记录您 灵感和创意

坚果云Markdown下载坚果云Markdown介绍