title: Using for loop for statistics by data frame column in R
body: <p>I have been trying to make a loop that takes a vector of the column names I want to use and then does a loop for statistical tests to a column that determines the group of the sample. Here is how it looks for now.</p>
  
  <pre><code>sink('df_statistics.txt')
  
  df &lt;- `df.tsv`
  
  columns &lt;- c("column1" , "column2" , "column3" , "column4")
  
  for (x in columns) {
      wilcox.test(formula = x ~ Group, data = df)
  }
  
  sink()
  </code></pre>
  
  <p>When I run it I get this error:</p>
  
  <blockquote>
    <p>Error in model.frame.default(formula = data ~ Group, data = df) :<br>
    variable lengths differ (found for 'Group')</p>
  </blockquote>
  
  <p>My groups are determined by the numbers 1 and 2. 
  I also tried naming them control and experimental but I keep getting the same error as above. Any suggestions? </p>