DarkSide DarkSide - 1 year ago 66
R Question

Using Data from Environment in R Markdown

Im trying to use data from Global Environment in R Markdown. When i call a

it gives me this error:

object 'mydata' not found

I got all my work in many different scripts, so is not easy for me create a
file for each result.

So, can i call data defined on Global Environment in R Markdown?

Thank You.

Answer Source

There are 2 ways to load the data "myData" to your .RMD file:



This will take your recent environment into account and the error should be gone.

  1. Store your "myData" as "myData.RData" and load it manually in your RMD file

    ```{r load myData, include=FALSE}

    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.