title: Remove y part from the x part in formula in R
body: <p>I have list of 12 Dataframes. one Dataframe looks like below:</p>
  
  <pre><code>df12&lt;-data.frame(a.Boston=c(8,8),a.Hartford=c(6,6),a.Denver=c(8,8),b.Boston_12=c(8,8),b.Denver_12=c(6,6))
  </code></pre>
  
  <p>df12:</p>
  
  <pre><code>   a.Boston a.Hartford a.Denver b.Boston_12 b.Denver_12
      1        8          6        8           8           6
      2        8          6        8           8           6
  </code></pre>
  
  <p>And I am trying to create formula for each dataframe. Code is given below 
  for creating a formula:</p>
  
  <pre><code>myformula&lt;-lapply(1:12, function(x) as.formula(paste(paste0("a.", df[['city']][1], " ~ "), 
                                                       paste(sprintf("`%s`", colnames(get(paste0("df",x)))), collapse="+")))
  )
  </code></pre>
  
  <p>My formula contains y part in x also. For example:</p>
  
  <p><strong>Formula10</strong>:</p>
  
  <pre><code>a.Boston ~ a.Boston + a.Hartford + a.Denver + b.Boston_10 + b.Boston_11 + 
    b.Boston_12 + b.Denver_10 + b.Denver_11 + b.Denver_12
  </code></pre>
  
  <p><strong>Formula12:</strong></p>
  
  <pre><code>a.Boston ~ a.Boston + a.Hartford + a.Denver + b.Boston_12 + b.Denver_12
  </code></pre>
  
  <p>So, I want to remove y part from the x part in the formula.</p>