I want to convert all the coloumns of my dataframe to numeric format. So I use lapply
data.frame(lapply(dat, numeric))
But this is showng me an invalid length argument error. However, it is working when I tried with individual coloumns.
lapply(dat$x.Type, numeric)
But then again I am left to wonder how to update the orginal dataframe with this.
I am guessing the solution to my problem is to run a loop applying lapply through all the coloumns . The problem is I am having trouble figuring out how to do that.
Could somebody help me?
Try using as.numeric
instead of numeric
:
dat <- as.data.frame(lapply(dat, as.numeric))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With