title: Calling variable in the loop by using assign and paste0
body: <p>I have a variable named SAL_mean created like this (I want to make a loop once I figure this out):</p>
  
  <pre><code>watersheds &lt;- c('ANE', 'SAL', 'CER')
  assign(paste0(watersheds[1], '_mean'), read.csv(paste0(watersheds[1], '_mean.csv')))
  </code></pre>
  
  <p>now the next step should be something like this (which works):</p>
  
  <pre><code>cols_dont_want &lt;- c('B1', 'B2', 'B3')
  assign(paste0(watersheds[1], '_mean'), SAL_mean[, !names(SAL_mean) %in% cols_dont_want])
  </code></pre>
  
  <p>but I wanted to ask how to replace "SAL_mean" by using watersheds[1], because this line of code doesn't work:</p>
  
  <pre><code>assign(paste0(watersheds[1], '_mean'), paste0(watersheds[1], '_mean')[, !names(paste0(watersheds[1], '_mean')) %in% cols_dont_want])
  </code></pre>
  
  <p>I think it treats the "paste0(watersheds[2], '_mean')" as string and not as a name of variable but I haven't been able to find a solution (I tried for example "as.name" function but it gave me an error "object of type 'symbol' is not subsettable")</p>