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

How to pass parameters to rmdshot? #63

Open
sdk2116 opened this issue Mar 27, 2018 · 8 comments
Open

How to pass parameters to rmdshot? #63

sdk2116 opened this issue Mar 27, 2018 · 8 comments

Comments

@sdk2116
Copy link

sdk2116 commented Mar 27, 2018

I am working with rmdshot and I am trying to pass parameters through to the function similar to how it is done here: https://rmarkdown.rstudio.com/developer_parameterized_reports.html

I assume that this can be done using "rmd_args", but I am having no luck. Can you please provide an example as to how "params" can be passed through to rmd_args?

Thank you!

@wch
Copy link
Owner

wch commented Mar 27, 2018

If you were to render the Rmd file to html, you'd do the following

rmarkdown::render("test.Rmd", params = list(foo = 200))

With rmdshot(), it works like this:

webshot::rmdshot("test.Rmd", rmd_args = list(params = list(foo = 200)))

This is an example Rmd document that works with the commands above.

---
title: "Test"
output: html_document
params:
  foo: 123
---

```{r}
params$foo
```

@wch wch closed this as completed Mar 27, 2018
@sdk2116
Copy link
Author

sdk2116 commented Mar 27, 2018

I keep getting this error message: ERROR: Only know how to handle numbers and strings arguments to rmarkdown::render. Don't know how to handle argument 1.

@wch
Copy link
Owner

wch commented Mar 28, 2018

This sounds like an issue with using rmarkdown::render. I think that you'll be able to find help for this on StackOverflow or https://community.rstudio.com/.

@sdk2116
Copy link
Author

sdk2116 commented Mar 28, 2018

It seems like the error that is being passed back is coming from rmdshot, please see below:

item_to_arg_string <- function(name, val) {
if (is.numeric(val))
as.character(val)
else if (is.character(val))
paste0('"', val, '"')
else
stop("Only know how to handle numbers and strings arguments to rmarkdown::render. ",
"Don't know how to handle argument ", val, ".")

}

It appears that this error is occuring before reaching rmarkdown::render

@wch
Copy link
Owner

wch commented Mar 28, 2018

It would help if you provided a reproducible example. Also, the output of sessionInfo(), or better, devtools::session_info().

@wch wch reopened this Mar 28, 2018
@wch
Copy link
Owner

wch commented Mar 29, 2018

Another thought: you should try the latest development version of webshot, because it changed the code for Rmd files. To install, you'll need the devtools package, and then run:

devtools::install_github('wch/webshot')

@sdk2116
Copy link
Author

sdk2116 commented Apr 3, 2018

For some reason I am receiving a timeout issue using the Github version of webshot. I would send over the sessionInfo, but I am running the code on a shiny server and I am unsure of how to output the sessioninfo and send it over. Could the issue be that I am running rmdshot on a shiny output of rmarkdown?

@camillejo
Copy link

I am trying to do this with a document using runtime: shiny. It works fine until I try to pass parameters to the R markdown file. Then I get the following message: "Error: It took more than 60 seconds to launch the Shiny Application. There may be something wrong. The process has been killed. If the app needs more time to be launched, set options(webshot.app.timeout) to a larger value." Do you have any idea why this times out? I'd prefer to run this on the shiny version of this markdown document because the plain html version doesn't resize my plotly plot correctly. Thanks for your help!

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

No branches or pull requests

3 participants