Reputation: 479
When I run a knitr document in R Studio, a variable is assigned. I can see this from the generated PDF-file.
Although this variable is not loading into my Global Environment.
My working directory is set in the knitr document. In R studio I use the same working directory.
Is there a method to load the variables into my Global Environment by using knitr?
Thank you.
This is the code:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document.
```{r section1, echo=TRUE}
getwd()
# set the URL for the download
wwwTrain <- "http://d396qusza40orc.cloudfront.net/predmachlearn/pml-training.csv"
training <- read.csv(url(wwwTrain))
```
Upvotes: 1
Views: 1132
Reputation: 146
You can manually render your document within the global environment by executing this in the RStudio console:
rmarkdown::render("my_document.Rmd", envir=.GlobalEnv)
I do this frequently and wrote an RStudio Addin for this purpose.
Upvotes: 3