title: trouble with cbind in manova call in r
body: <p>I'm trying to do a multivariate ANOVA with the manova function in R. My problem is that I'm trying to find a way to pass the list of dependent variables without typing them all in manually, as there are many and they have horrible names. My data are in a data frame where "unit" is the dependent variable (factor), and the rest of the columns are various numeric response variables. e.g.</p>
  
  <pre><code>  unit C_pct  Cln C_N_mol Cnmolln C_P_mol N_P_mol
  1    C 48.22 3.88   53.92    3.99 3104.75   68.42
  2    C 49.91 3.91   56.32    4.03 3454.53   62.04
  3    C 50.75 3.93   56.96    4.04 3922.01   69.16
  4   SH 50.72 3.93   46.58    3.84 2590.16   57.12
  5   SH 51.06 3.93   43.27    3.77 2326.04   53.97
  6   SH 48.62 3.88   40.97    3.71 2357.16   59.67
  </code></pre>
  
  <p>If I write the manova call as</p>
  
  <pre><code>fit &lt;- manova(cbind(C_pct, Cln) ~ unit, data = plots) 
  </code></pre>
  
  <p>it works fine, but I'd like to be able to pass a long list of columns without naming them one by one, something like</p>
  
  <pre><code>fit &lt;- manova(cbind(colnames(plots[5:32])) ~ unit, data = plots) 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>fit &lt;- manove(cbind(plots[,5:32]) ~ unit, data = plots)
  </code></pre>
  
  <p>I get the error </p>
  
  <pre><code>"Error in model.frame.default(formula = as.matrix(cbind(colnames(plots[5:32]))) ~  : 
    variable lengths differ (found for 'unit')
  </code></pre>
  
  <p>I'm sure it's because I'm using cbind wrong, but can't figure it out. Any help is appreciated! Sorry if the formatting is rough, this is my first question posted.</p>
  
  <p>EDIT: Both ways (all 3, actually) work. thanks all!</p>