title: Passing values from an Rnw file to an R script
body: <p>Since I am a newbie as far as knitr is concerned, I am reading and modifying the examples given in knitr web site. One the approaches that caught my attention is to call chunks of an R script within an Rmw file. After compiling and modifying several examples, I wonder whether one can set a variable on an Rmw file and pass it to an R-script.</p>
  
  <p>Here is an example</p>
  
  <pre><code>\documentclass{article}
  \begin{document}
  &lt;&lt;set-options, echo=FALSE, cache=FALSE&gt;&gt;=
  options(replace.assign=TRUE)
  opts_chunk$set(cache=TRUE, fig.show='asis')
  read_chunk('simple_example.R')
  @
  
  \title{Example}
  \author{Somebody}
  \maketitle
  
  \section{Print variable}
  
  &lt;&lt;Print-data, echo=TRUE&gt;&gt;=
  inp=2
  @
  
  \end{document}
  </code></pre>
  
  <p>and</p>
  
  <pre><code># Simple Example
  
  ## ---- Print-data ----
  
  inp=inp+2
  print(inp)
  </code></pre>
  
  <p>The output result is ip=2 and an error msg "object inp not found".</p>
  
  <p>Many thanks</p>