I am trying to coerce all the columns in a data frame as 'numeric' as a step previous to run lm() over it. One of the columns is read by R as a 'character', so I tried this:
df <- data_frame
for (i in colnames(df)){
if (is.numeric(df[i]) == FALSE){
df[i] == as.numeric(df[i])
}
}
And I get this error:
Error in as.numeric(df[i]) : 'list' object cannot be coerced to type 'double'
Any ideas about what's happening?