in R, dec="," does not work in read.csv2

2

Good afternoon ... I'm trying to import csv where the decimals are separated by a point ... or something like 2.5

I want it to come up with a comma, something like that, 2,5

 uo_14<- read.csv2("csv\uo_2014.csv", as.is = FALSE , header = TRUE, 
                     sep = ",", dec=",", encoding='UTF-8' )


 uo_14
    nome   valor1  valor 2
    nome1   3.5      3.6
    nome2   5.4      1.7

I do not know what's wrong!

    
asked by anonymous 29.11.2014 / 17:49

1 answer

3

If the goal is just to change how the R output displays the decimal separator, you can use:

options(OutDec = ",")

See the description of the Outdec option in the help page of the options ( ?options ) function for more information.

In addition, if your csv file uses dot as a decimal separator, then you should use dec = "." in the read.csv2 function:

uo_14 <- read.csv2("csv\uo_2014.csv", as.is = FALSE, header = TRUE, 
                 sep = ",", dec = ".", encoding='UTF-8')
    
30.11.2014 / 01:40