I try to convert some columns in data.frame from integer to numeric. And this piece of code works well.
test.data[] <- lapply(test.data, function(x) if(is.integer(x)) as.numeric(x) else x)
But when I use ifelse instead of if...else....The result is nonsense.
test.data[] <- lapply(test.data, function(x) ifelse(is.integer(x), as.numeric(x), x))
Why and what is the exactly difference between if...else and ifelse here? Thanks a lot.