Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knit2wp can't see params when run from command line #1934

Open
3 tasks done
arencambre opened this issue Dec 19, 2020 · 3 comments
Open
3 tasks done

knit2wp can't see params when run from command line #1934

arencambre opened this issue Dec 19, 2020 · 3 comments
Labels
bug Bugs

Comments

@arencambre
Copy link

I have an R script that contains this command:

knit2wp(
  input = 'analysis.Rmd',
  title = 'COVID-19 stats for Dallas and Texas',
  publish = TRUE,
  action = "editPost",
  postid = 3275
)

The Rmd file has many plots, and the subtitle field of each uses a parameter.

When I run that script from RStudio, it works fine. The page looks fine.

When I run that script from the command prompt, using rscript.exe, every plot is substituted with this error text: ## Error in list2(..., title = title, subtitle = subtitle, caption = caption, : object 'params' not found

I've reproduced this on two machines, both running Windows 10H2 and R 4.0.3. One has RStudio 1.3, the other has RStudio 1.4 Preview.

This is my YAML header:

---
title: "COVID-19 stats for Dallas and Texas"
params:
  use_cache: TRUE
  produced_by: "produced by Aren Cambre"
output:
  html_document:
    df_print: paged
    toc: true
---

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Collaborator

cderv commented Dec 21, 2020

For reference, this has also been asked on the community https://community.rstudio.com/t/knitr-from-command-line-object-params-not-found/91269/3

(Per the issue guide, it really helps us that cross posting is mentioned)

@cderv cderv added the bug Bugs label Dec 21, 2020
@arencambre
Copy link
Author

arencambre commented Dec 31, 2020

I am now getting this same problem if I run knit2wp() from an R script from within RStudio. Between this time and the last time I successfully ran my script (from within RStudio), the only change is I upgraded to the latest versions of these packages:

  • rlang 0.4.10
  • cowplot 1.1.1
  • ggplot2 3.3.3
  • data.table 1.13.6

Only ggplot2 is explicitly used by my script. I am almost certain cowplot is not used. If rlang and data.table are used, it would only be reference.

For now, my workaround is to manually create a params list:

params <- list(produced_by = "string goes here")

@arencambre
Copy link
Author

I made a trivial example and cannot reproduce. That doesn't mean the issue is invalid, just means the root cause may be harder to discern.

Relevant files attached. Note path in first line of the R script.
test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

2 participants