How do I find co-linear variables in R Suppose my data consisted of the data in the dataframe df (below) -- which columns would I drop x, y or z for methods that are allergic to correlated variables?
library(corrplot)
x <- seq(0, 100, 1)
# colinear with x
y <- x + 2.3 
# almost colinear with x / some small gaussian noise 
z <- x + rnorm(mean = 0, sd = 5, n = 101)
# uncorrrelated gaussian 
w <- rnorm(mean = 0, sd = 1, n = 101)

# this frame is made to exemplify the procedure
df <- data.frame(x = x, y = y, z = z, w = w)

corr.matrix <- cor(df)
corrplot.mixed(corr.matrix)

 A: An easy way to select features is caret::findCorrelation, which determines features to be left out for optimal inter-feature-correlation, and where the allowed feature correlation can be set using a cutoff parameter:
library(corrplot)
corrplot(cor(df))
library(caret)
indexesToDrop <- findCorrelation(cor(df), cutoff = 0.8)
corrplot(cor(df[,-indexesToDrop]))

This feature selection boils down to a search problem: in each step, the feature with the highest correlation to other features should be removed, which is also stated in ?findCorrelation:

The absolute values of pair-wise correlations are considered. If two variables have a high correlation, the function looks at the mean absolute correlation of each variable and removes the variable with the largest mean absolute correlation

What remains is to find a suitable amount of allowed feature correlation, which will depend on your problem and model.
A: What I sometimes do, is a bit hacky, but does just what you want:
#drop perfectly multicollinear variables
constant<-rep(1,nrow(df))
tmp<-lm(constant ~ ., data=df)
to_keep<-tmp$coefficients[!is.na(tmp$coefficients)]
to_keep<-names(to_keep[-which(names(to_keep) == "(Intercept)")])
df_result<-df[to_keep]

A: In your example it is not possible to tell which feature should drop. Because all of your data come from simulation.
In real world it is a different story. Suppose you have two measures on a person's weight, one is in lb and another is in kg. Not only they are highly correlated, but also they are identical. 
As you suggested, if you are using some model not "allergic" to collinearity problem (like tree model), you can keep both. But if you are fitting with a linear model, and you must drop one. You can chose anyone to drop. But if you are in U.S. may be you want to drop the weight in kg unit. Of course, in real world you will not have identical features, but have similar features. you may need to investigate which one has "more information"
In sum, my answer is which one to drop depends on your domain needs and information contained in the feature.
