I am trying to apply a single function to find the correlation between all numeric columns and the target variable (separately, one by one)
This is the code I was able to determine a single column's correlation. I'm trying to limit my correlations above 0.4:
> if(abs(cor(train$YearBuilt, train$SalePrice)) > .4) {
+ print(abs(cor(train$YearBuilt, train$SalePrice)))
+ }
[1] 0.5228973
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.