There is a nice discussion of how to convert character into numerics in this SO here. Maybe I missed something in that post, but what would one do if one does not know which columns are "convertable" (if any) ? Is it possible to check for convertability ? In addition, I usually suppress factor conversion (like character better) - so characters should be characters (not factors).
df <- data.frame(a=as.character(c(NA, 1/3)), b=letters[1:2], c=c('1|2', '4|2'), d=as.character(3:4), stringsAsFactors = F)
Then apply ... some function f
... to get:
str(f(df))
'data.frame': 2 obs. of 4 variables:
$ a: num NA 0.333
$ b: chr "a" "b"
$ c: chr "1|2" "4|2"
$ d: int 3 4
How to achieve this for any data.frame not known beforehand ?