title: applying correlation to all columns in R
body: <p>I am trying to apply a single function to find the correlation between all numeric columns and the target variable (separately, one by one)</p>
  
  <p>This is the code I was able to determine a single column's correlation. I'm trying to limit my correlations above 0.4:</p>
  
  <pre><code>&gt; if(abs(cor(train$YearBuilt, train$SalePrice)) &gt; .4) {
  +       print(abs(cor(train$YearBuilt, train$SalePrice)))
  +     }
  [1] 0.5228973
  </code></pre>
  
  <p>I would like to be able to print the column name followed by the correlation, and then the next column name and its correlation, etc. </p>