Thanks for getting me pointed in the right direction. If I happen upon a satisfactory solution, I will report back!
Nate Parsons Pronouns: He, Him, His Graduate Teaching Assistant Department of Sociology Portland State University Portland, Oregon Schedule an appointment: https://calendly.com/nate-parsons 503-893-8281 503-725-3957 FAX Nate Parsons Pronouns: He, Him, His Graduate Teaching Assistant Department of Sociology Portland State University Portland, Oregon Schedule an appointment: https://calendly.com/nate-parsons 503-893-8281 503-725-3957 FAX On Sun, Dec 16, 2018 at 1:46 PM Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > > This seems a bit deep into knitr for R-help... you might have better luck on > StackExchange. I also suggest that posting an incomplete example is usually > the kiss of death for getting constructive assistance online. > > FWIW my guess is that executing knitr from within an Rmarkdown document is a > bad idea unless you are building using child documents. Try manipulating your > markdown from an R file. > > On December 16, 2018 11:48:44 AM PST, Nathan Parsons > <nathan.f.pars...@gmail.com> wrote: > >Goal: post from R to Wordpress installation on server. > > > >Problem: R keeps returning the error “Error in parse_block(g[-1], > >g[1], params.src) : duplicate label 'setup’” if error = FALSE in the > >knitr options or in an r chunk. It works fine if error = TRUE. I could > >just go through each post each time and remove any returned errors > >manually, but I'd like to find a more permanent solution. > > > >I don't have any duplicate labels; is knit2wp somehow introducing a > >duplicate label in the .Rmd > >-> .md / upload process? > > > >My code: > > > >```{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) > >``` > > > > > >Traceback: > >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") > > > >______________________________________________ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide > >http://www.R-project.org/posting-guide.html > >and provide commented, minimal, self-contained, reproducible code. > > -- > Sent from my phone. Please excuse my brevity. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.