Rstudio doesn't do knit Word stories

I seem to have discovered strange behavior with the knit Word command in RStudio

It works:

```{r qplot, fig.width = 6, fig.height=6, message=FALSE} library(ggplot2) summary(cars) qplot(speed, dist, data = cars) + geom_smooth() ```` 

this does not work

  ```{rq plot, fig.width = 6, fig.height=6, message=FALSE} library(ggplot2) summary(cars) qplot(speed, dist, data = cars) + geom_smooth() ``` 

returns this message:

  pandoc.exe: Could not find image `./test_files/figure-docx/q%20plot.png', skipping... 

The problem seems to be related to the name of the part (i.e. qplot vs. q plot ). When there is a space in the fragment name, the chart is not displayed.

This seems to affect the rendering of Word documents. Rendering html works great.

I am using RStudio 0.98.1028 and R3.1.1 for Windows 7.

Has anyone else encountered this behavior?

Update

a space after the chunk name also causes the same behavior:

this does not work

  ```{r q_plot , fig.width = 6, fig.height=6, message=FALSE} library(ggplot2) summary(cars) qplot(speed, dist, data = cars) + geom_smooth() ``` 
+5
source share
2 answers

Publication of the decision in case someone encounters this in the future.

From Ben Bolker in the comments of Avoid spaces and periods . in chunk labels and directory names Avoid spaces and periods . in chunk labels and directory names , as stated in the knitr documentation http://yihui.name/knitr/options .

This error only affects charting using knitWord. Code fragments with labels that contain spaces and which do not display display commands display normally. knitHTML also works fine, regardless of whether the piece labels space or not.

+3
source
 # Let make a plot ```{r ugly plot} plot(btc_prices) ``` 

should be, should be

 # Let make a plot ```{r ugly_plot} plot(btc_prices) ``` 

So there are no spaces ... otherwise you will spend hours searching and sending out.

0
source

Source: https://habr.com/ru/post/1201265/


All Articles