title: Applying univariate coxph function to multiple covariates (columns) at once
body: <p>First, I gathered from this link <a href="https://stackoverflow.com/questions/32570988/applying-a-function-to-multiple-columns">Applying a function to multiple columns</a> that using the "function" function would perhaps do what I'm looking for.  However, I have not been able to make the leap from thinking about it in the way presented to making it actually work in my situation (or really even knowing where to start).  I'm a beginner in R so I apologize in advance if this is a really "newb" question.  My data is a data frame that consists of an event variable (tumor recurrence) and a time variable (followup time/time to recurrence) as well as recurrence risk factors (t-stage, tumor size,age at dx, etc.). Some risk factors are categorical and some are continuous. I have been running my univariate analysis by hand, one at a time like this example univariateageatdx&lt;-coxph(survobj~agedx), and then collecting the data.  This gets very tedious for multiple factors and doing it for a few different recurrence types.  I figured there must be a way to code such that I could basically have one line of code that had the coxph equation and then applied it to all of my variables of interest and spit out a result that had the univariate analysis results for each factor. I tried using cbind to bind variables (i.e <code>x&lt;-cbind("agedx","tumor size")</code> then running cox <code>coxph(recurrencesurvobj~x)</code> but this of course just did the multivariate analysis on these variables and didn't split them out as true univariate analyses.  </p>
  
  <p>I also tried the following code based on a similar problem that I found on a different site, but it gave the error shown and I don't know quite what to make of it.  Is this on the right track? </p>
  
  <pre><code>f &lt;- as.formula(paste('regionalsurvobj ~', paste(colnames(nodcistradmasvssubcutmasR)[6-9], collapse='+')))
  </code></pre>
  
  <p>I then ran it has coxph(f) 
  Gave me the results of a multivariate cox analysis.</p>
  
  <p>Thanks! 
  **edit: I just fixed the error, I needed to use the column numbers I suppose not the names.  Changes are reflected in the code above.  However, it still runs the variables selected as a multivariate analysis and not as the true univariate analysis... </p>