How to simplify nested conditional for loop in R?
This bit:

for (i in 1:m) {
  if(i == 1 &amp;&amp; x == 'site') {
    vars &lt;- c(vars, 'beta.site[1]')
  }
  if (i &gt; 1) {
    vars &lt;- c(vars, paste('beta.', x, '[', i, ']', sep=''))
  }
}


Says handle the first pass differently from all the others.  So I would replace it with this:

if (x == 'site') {
  vars &lt;- c(vars, 'beta.site[1]')
}
for (i in 2:m) {
  vars &lt;- c(vars, paste('beta.', x, '[', i, ']', sep=''))
}