Skip to content

comma as a seperator to numeric

3 messages · Ivan Calandra, Mat

Mat
#
Hello together,

i have a big problem, to convert a column in my data.frame to numeric.

I have:
61,13 in the column and write:
data$PT_DL<-as.numeric(as.character(data$PT_DL))

the result is NA, not a point seperated number.

How can i change the data to an as.numeric number?

Thank you for your help.

Mat



--
View this message in context: http://r.789695.n4.nabble.com/comma-as-a-seperator-to-numeric-tp4651090.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi Mat,

You could first replace your commas with points using gsub().
Or you could import your data differently (using read.csv2() for example)

See ?gsub and ?read.csv

HTH,
Ivan

--
Ivan CALANDRA
Universit? de Bourgogne
UMR CNRS/uB 6282 Biog?osciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calandra at u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 28/11/12 09:03, Mat a ?crit :