Reputation: 31
i am trying to move plot results in to rmarkdown in R studio the following code fails
```{r front_stuff ,echo=FALSE,fig.height=3,fig.width=4}
library(ggplot2)
library(cowplot)
library(lubridate)
library(reshape2)
library(htmlTable)
library(data.table)
library(png)
project_folder<-"C:\\Users\\jciconsult\\SkyDrive\\trial_retail\\"
load(paste0(project_folder,"sa_prov_html.RSave"))
load(paste0(project_folder,"Ontario_plot_save.RSave"))
ls()
```
`r ggdraw(cow_plot1)`
Error message is
Quitting from lines 29-29 (test1.Rmd) Error in
vapply(x, format_sci_one, character(1L), ..., USE.NAMES = FALSE)
: values must be length 1, butFUN(X[[1]])
result is length 2 Calls: ... paste -> hook -> .inline.hook -> format_sci -> vapply Execution halted
If I take the same code and copy it into a clear R session (eliminating the stuf for code blocks), everything works.
What I am trying to do is get a document that can convert to word. I am using the knit HTML option because that is needed to get my htmlTable output to work. I want something that I can cut and paste into word for final formatting,
Upvotes: 0
Views: 728
Reputation: 19867
The plot cannot be drawn because it is inline code. Try using a code chunk instead:
```{r}
ggdraw(cow_plot1)
```
Also, the proper way to set a working directory with knitr (which seems to be what you want to achieve) is with the knitr option root.dir
:
library(knitr)
opts_knit$set(root.dir = project_folder)
load("sa_prov_html.RSave")
load("Ontario_plot_save.RSave")
Upvotes: 2