R Knitr:错误= FALSE导致knit2wp抛出重复标签错误

时间:2018-12-16 19:22:52

标签: r wordpress knitr

目标:从R发布到服务器上的Wordpress安装。

问题:R不断返回错误

  

parse_block(g [-1],g [1],params.src)中的错误:重复标签'setup'

如果error = FALSE选项中的knitr 中的。如果error = TRUE可以正常工作。我可以每次浏览每个帖子,然后手动删除所有返回的错误,但是我想找到一个更永久的解决方案。

我没有重复的标签; knit2wp是否在.Rmd-> .md /上传过程中引入了重复标签?

代码如下:

```{r setup, include=FALSE}
## Set the global chunk options for knitting reports
knitr::opts_chunk$set(
        echo = TRUE,
        eval = TRUE,
        message = TRUE,
        error = FALSE,
        warning = TRUE,
        highlight = TRUE,
        prompt = FALSE
        )

## Load and activate libraries using 'pacman' package
if (!require(pacman)) {
  install.packages("pacman", repos = "http://cran.us.r-project.org")
  require(pacman)
}

pacman::p_load_gh("duncantl/XMLRPC", 
                  "duncantl/RWordPress")
pacman::p_load("knitr")
```

```{r chunk1, echo = FALSE}
## post information
fileName <- "fancy_post.Rmd"
postTitle <- "Fancy Post Title"

```

blah blah blah...

```{r chunk2, echo = FALSE}
## Set working directory to correct location
last_dir <- getwd()
setwd("~/Sites/posts")

## Tell knitr to create the html code and upload it to your wordpress site
knit2wp(input = fileName, 
        title = postTitle, 
        publish = FALSE, 
        action = 'newPost')

setwd(last_dir)
```

这是回溯:

Error in parse_block(g[-1], g[1], params.src) : duplicate label 'setup'
26. stop("duplicate label '", label, "'")
25. parse_block(g[-1], g[1], params.src)
24. FUN(X[[i]], ...)
23. lapply(groups, function(g) { block = grepl(chunk.begin, g[1]) if (!set.preamble && !parent_mode()) { return(if (block) "" else g) ...
22. split_file(lines = text)
21. process_file(text, output)
20. knit(input, encoding = encoding, envir = envir)
19. knit2wp(input = fileName, title = postTitle, publish = FALSE, action = "newPost")
18. eval(expr, envir, enclos)
17. eval(expr, envir, enclos)
16. withVisible(eval(expr, envir, enclos))
15. withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)
14. handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, error = eHandler, message = mHandler))
13. timing_fn(handle(ev <- withCallingHandlers(withVisible(eval(expr, envir, enclos)), warning = wHandler, error = eHandler, message = mHandler)))
12. evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, debug = debug, last = i == length(out), use_try = stop_on_error != 2L, keep_warning = keep_warning, keep_message = keep_message, output_handler = output_handler, include_timing = include_timing)
11. evaluate::evaluate(...)
10. evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (options$error && options$include) 0L else 2L, output_handler = knit_handlers(options$render, options))
9. in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (options$error && options$include) 0L else 2L, output_handler = knit_handlers(options$render, options)))
8. block_exec(params)
7. call_block(x)
6. process_group.block(group)
5. process_group(group)
4. withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), error = function(e) { setwd(wd) cat(res, sep = "\n", file = output %n% "") ...
3. process_file(text, output)
2. knit(input, encoding = encoding, envir = envir)
1. knit2wp(input = fileName, title = postTitle, publish = FALSE, action = "newPost")

0 个答案:

没有答案
相关问题