I was reading this question at SO and was wondering if there is any way to use is.numeric in a vectorized way. The point being, if you have a vectorized way to check if a variable is numeric, then any function what depends on the variable being numeric can be vectorized. Otherwise, it cannot be vectorized.
Share
As per the comments:
if you’re looking to test columns of a data.frame with as.numeric, use
sapplyorlapply(but notapply)Or, for variety, you can use
colwisefrom the plyr package: