I have a set of Latitudes stored in VARCHAR format in mysql database-
"[26.455359183496455,26.44229519242908,26.437069181137474,26.45489812668682]"
I have imported them in R and I want to work with them by converting them as float. I know that as.numeric() is used for conversion but how to apply it in my case.
someone please guide me.
You can do this in three steps.
gsub(), strsplit(), as.numeric()). For exampleIn code this looks like
input <- "[26.455359183496455,26.44229519242908,26.437069181137474,26.45489812668682]"
as.numeric(strsplit(gsub("(^\\[|\\]$)", "", input), ",")[[1]])
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