R markdown source R code doesn't seem to work
<p>This seems simple but I can't get my head around why it isn't working...
I have a Rmarkdown file(test.Rmd) in which I'm sourcing an R file(test1.R), the code in sourced R file doesn't seem to access the objects in Rmarkdown file - why?</p>

<p>content of test.Rmd :</p>

<pre><code>---
title: "Test"
runtime: shiny
output: html_document
---
```{r echo=FALSE,results='asis',message=FALSE}
library(data.table)
x&lt;-data.table(a=1,b=2)
source("test1.R")
{knitr::kable(x1)}
``` 
</code></pre>

<p>Content of test.R</p>

<pre><code>x1&lt;-x
</code></pre>

<p>The error while running the document is :</p>

<pre><code>Error : Object 'x' not found
</code></pre>

<p>Why doesn't sourced commands couldn't access the objects in the calling scope?</p>