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

the PNG device produces... pdf files #17

Closed
joelgombin opened this issue Jul 19, 2019 · 3 comments
Closed

the PNG device produces... pdf files #17

joelgombin opened this issue Jul 19, 2019 · 3 comments

Comments

@joelgombin
Copy link

I try to knit this .Rmd file:

---
title: "test"
date: "19/07/2019"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.path = "./figures_test/", dev = ragg::agg_png())
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure}
plot(pressure)
```

But the plot files generated are... pdf file. And if I try to force the fig.ext knitr parameter, I get (as I should) PDFs with png extensions.

And here is the output of devtools::session_info():

─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       Ubuntu 18.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  fr_FR.UTF-8                 
 ctype    fr_FR.UTF-8                 
 tz       Europe/Paris                
 date     2019-07-19                  

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source        
 assertthat    0.2.1   2019-03-21 [3] CRAN (R 3.5.3)
 backports     1.1.4   2019-04-10 [3] CRAN (R 3.5.3)
 callr         3.2.0   2019-03-15 [3] CRAN (R 3.5.3)
 cli           1.1.0   2019-03-19 [3] CRAN (R 3.5.3)
 crayon        1.3.4   2017-09-16 [3] CRAN (R 3.5.0)
 desc          1.2.0   2018-05-01 [3] CRAN (R 3.5.0)
 devtools      2.0.2   2019-04-08 [3] CRAN (R 3.5.3)
 digest        0.6.19  2019-05-20 [3] CRAN (R 3.6.0)
 evaluate      0.14    2019-05-28 [3] CRAN (R 3.6.0)
 fs            1.3.1   2019-05-06 [3] CRAN (R 3.6.0)
 glue          1.3.1   2019-03-12 [3] CRAN (R 3.5.3)
 htmltools     0.3.6   2017-04-28 [3] CRAN (R 3.5.0)
 knitr         1.23    2019-05-18 [3] CRAN (R 3.6.0)
 magrittr      1.5     2014-11-22 [3] CRAN (R 3.5.0)
 memoise       1.1.0   2017-04-21 [1] CRAN (R 3.6.0)
 packrat       0.5.0   2018-11-14 [1] CRAN (R 3.6.0)
 pkgbuild      1.0.3   2019-03-20 [3] CRAN (R 3.5.3)
 pkgload       1.0.2   2018-10-29 [3] CRAN (R 3.5.1)
 prettyunits   1.0.2   2015-07-13 [3] CRAN (R 3.5.0)
 processx      3.3.1   2019-05-08 [3] CRAN (R 3.6.0)
 ps            1.3.0   2018-12-21 [3] CRAN (R 3.5.2)
 R6            2.4.0   2019-02-14 [3] CRAN (R 3.5.2)
 Rcpp          1.0.1   2019-03-17 [3] CRAN (R 3.5.3)
 remotes       2.1.0   2019-06-24 [3] CRAN (R 3.6.0)
 rlang         0.4.0   2019-06-25 [1] CRAN (R 3.6.0)
 rmarkdown     1.13    2019-05-22 [1] CRAN (R 3.6.0)
 rprojroot     1.2     2017-01-16 [3] CRAN (R 3.5.0)
 rsconnect     0.8.13  2019-01-10 [1] CRAN (R 3.6.0)
 rstudioapi    0.10    2019-03-19 [3] CRAN (R 3.5.3)
 sessioninfo   1.1.1   2018-11-05 [3] CRAN (R 3.5.1)
 testthat      2.1.1   2019-04-23 [1] CRAN (R 3.6.0)
 usethis       1.5.0   2019-04-07 [3] CRAN (R 3.5.3)
 withr         2.1.2   2018-03-15 [3] CRAN (R 3.5.0)
 xfun          0.8     2019-06-25 [1] CRAN (R 3.6.0)
 yaml          2.2.0   2018-07-25 [3] CRAN (R 3.5.1)

[1] /home/joel/R/x86_64-pc-linux-gnu-library/3.6
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
@thomasp85
Copy link
Member

I’m pretty sure you cannot control which device implementation is used by knitr — support for ragg is something you’ll have to take up with them

@joelgombin
Copy link
Author

Ah? And yet the documentation of knitr (for the dev parameter) says:

if none of the 20 built-in devices is appropriate, we can still provide yet another name as long as it is a legal function name which can record plots (it must be of the form function(filename, width, height))

So I took it I could plug in any device in it? Am I wrong in thinking that?

@thomasp85
Copy link
Member

I don't know about that functionality, honestly... but I can see a couple of issues. You are not passing in a function to dev but agg_png() which evaluates to NULL (probably why you get a pdf). Secondly agg_png() does not have the requested signature as it takes more than filename, width, and height...

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

2 participants