rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.88k stars 975 forks source link

When param default is NULL, error when trying to pass parameter value #729

Closed wch closed 7 years ago

wch commented 8 years ago

For example, this document and code produce an error:


---
output: html_document
params:
  x: NULL

---

```{r}
params$x

``` R
rmarkdown::render("test.Rmd", params = list(x=1))
# Error in knit_params_get(input_lines, params) : 
#  render params not declared in YAML: x 

But if you change the default in the YAML header to x: NA, it works fine.

stevekm commented 8 years ago

I had the same problem, but even changing to NA did not fix it. I had to fill in some default value.

yihui commented 7 years ago

Fixed via #1115.

stevekm commented 6 years ago

@yihui which version of knitr did this fix go into?

yihui commented 6 years ago

@stevekm rmarkdown 1.7, released in Nov last year: https://github.com/rstudio/rmarkdown/releases/tag/v1.7

stevekm commented 6 years ago

Thanks. Not sure if its too off-topic an issue to post here, but I am having trouble getting that version installed with conda;

base install:

conda install -y -c r r-base \
r=3.3.2 \
r-base=3.3.2 \
pandoc==1.15.0.6 \
r-reshape2 \
r-knitr=1.15.1 \
r-rmarkdown \
r-ggplot2

Available versions:

root@521e956ad803:/# conda search r-rmarkdown
Loading channels: done
Name                       Version                   Build  Channel
r-rmarkdown                0.5.1                  r3.1.3_0  defaults
r-rmarkdown                0.5.1                 r3.1.3_0a  defaults
r-rmarkdown                0.7                    r3.2.0_0  defaults
r-rmarkdown                0.7                   r3.2.0_0a  defaults
r-rmarkdown                0.7                    r3.2.1_0  defaults
r-rmarkdown                0.7                   r3.2.1_0a  defaults
r-rmarkdown                0.8                    r3.2.1_0  defaults
r-rmarkdown                0.8                   r3.2.1_0a  defaults
r-rmarkdown                0.8                    r3.2.2_0  defaults
r-rmarkdown                0.8                   r3.2.2_0a  defaults
r-rmarkdown                0.8.1                  r3.2.2_0  defaults
r-rmarkdown                0.8.1                 r3.2.2_0a  defaults
r-rmarkdown                0.9.6                  r3.3.1_0  defaults
r-rmarkdown                1.2                    r3.3.1_0  defaults
r-rmarkdown                1.2                    r3.3.2_0  defaults
r-rmarkdown                1.3                    r3.3.2_0  defaults
r-rmarkdown                1.5                    r3.4.1_0  defaults
r-rmarkdown                1.6              r342hacd9e3e_2  defaults
r-rmarkdown                1.8             mro343h889e2dd_0  defaults
r-rmarkdown                1.8              r343h889e2dd_0  defaults

In R:

> library('rmarkdown')
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rmarkdown_1.3

loaded via a namespace (and not attached):
 [1] backports_1.0.4 magrittr_1.5    rprojroot_1.1   tools_3.3.2
 [5] htmltools_0.3.5 Rcpp_0.12.8     stringi_1.1.2   knitr_1.15.1
 [9] stringr_1.1.0   digest_0.6.10   evaluate_0.10

trying to install 1.8, since 1.7 is not showing up:

root@521e956ad803:/# conda install r-rmarkdown==1.8
Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - r-rmarkdown==1.8
  - r=3.3.2
Use "conda info <package>" to see the dependencies for each package.
yihui commented 6 years ago

Is there a particular reason why you are still using such an old version of R?

stevekm commented 6 years ago

was trying to maintain consistency with multiple servers we have still running R 3.3 with a working knitr + rmarkdown + pandoc stack, but it does not appear possible to replicate the exact library versions with conda. Upgrading to 3.4.3 appears to work though, thanks.

conda install -y -c r r-base \
r=3.4.3 \
r-base=3.4.3 \
pandoc \
r-reshape2 \
r-knitr \
r-rmarkdown \
r-ggplot2
github-actions[bot] commented 3 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.