Reputation: 297
I cannot show object in markdown document that are objects generated in different R script(within the same session). I would like to point out that I am newbie to markdown. So the code is as follows(''' are added before and after):
{r eval=TRUE, echo=FALSE}
head(output_by_size,10) # 1st line
summary(cars) # 2nd line
dim(iris) # 3rd line
when I comment line 2nd and 3rd the following error is generated: Error in head(output_by_size, 10) : object 'output_by_size' not found Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> head
When 1st line is commented, lines 2nd and 3rd work as expected. Output_by_size is just simple data frame object. Could you please help me out?
Upvotes: 0
Views: 2839
Reputation: 10362
There are 2 ways to load the data "output_by_size" to your .RMD file:
Don't knit your file with the Rstudio "knit" button, save your RMD file and then use the console:
library(knitr)
knit('your_file.Rmd')
This will take your recent environment into account and the error should be gone.
Store your "output_by_size" as "output_by_size.RData" and load it manually in your RMD file
```{r load myData, include=FALSE}
load("output_by_size.RData")
```
If you do it this way you can use the "knit" button from RStudio.
I hope one of this ways is a good solution for you.
Upvotes: 1