title: Variable as part of the name of a R object or Macros in R?
body: <p>is there any way to do a macro-style programming/variable substitution in R as it is possible in LaTeX or Unix-Shells? To be more concrete:</p>
  <p>How can I automize a line of code</p>
  <pre><code>    GehKennNr &lt;- read.csv(&quot;./Filename_202106.csv&quot;, header=T, sep=&quot;;&quot;, dec=',')
  </code></pre>
  <p>to</p>
  <pre><code>    ReadIn &lt;- function (YEAR) {
        GehKennNr$(YEAR) &lt;- read.csv(&quot;../Gehalt_Kennnr_$(YEAR).csv&quot;, header=T, sep=&quot;;&quot;, dec=',')
      }
  </code></pre>
  <p>so that I can call</p>
  <pre><code>    ReadIn(2016)
      ReadIn(2017)
  </code></pre>
  <p>and create data frames GehKennNr2016, GehKennNR2017?</p>
  <p>More generally: How to use a variable as part of the name of a R-object /data frame, variable (like GehKennNr2016$var2016 from the example above)?</p>
  <p>Thank you in advance.</p>