title: R - Dynamic reference to files for read csv
body: <p>I would like to make a script that reads data from the correct folder. I have several lines in my code refering to the foldername, therefore I would like to make this dynamic. Is it possible to make the reference to a folder name dynamic? See below what I would like to do</p>
  
  <pre><code># Clarifies the name of the folder, afterwards "Foldername" will be used as reference
  FolderA &lt;- Foldername
  # Read csv to import the data from the selected location
  data1 &lt;- read.csv(file="c:/R/Foldername/datafile1.csv", header=TRUE, sep=",")
  data2 &lt;- read.csv(file="c:/R/Foldername/datafile2.csv", header=TRUE, sep=",")
  </code></pre>
  
  <p>I am trying to get the same result as what I would get with this code:</p>
  
  <pre><code>data1 &lt;- read.csv(file="c:/R/FolderA/datafile1.csv", header=TRUE, sep=",")
  data2 &lt;- read.csv(file="c:/R/FolderA/datafile2.csv", header=TRUE, sep=",")
  </code></pre>
  
  <p>Can somebody please clarify how it would be possible to make this dynamic?</p>