Error importing decimal numbers into R

Asked

Viewed 147 times

3

I am trying to import a decimal column in csv (part of a dataset) through the function read_delim. However, columns with decimal numbers (comma-separated in the original dataset) are coming as integers.

Ex:

  • 175.60 appears as 17560
  • 98,6851 appears as 986851

Someone knows how I fix it?

  • Try to use the argument dec = ","

  • The function read_delim (and his sisters read_csv, read_csv2 and read_tsv) does not have the argument dec.

1 answer

4


The function read_delim cannot handle comma numbers. Use the function read.csv with the argument dec=",":

read.csv(file="arquivo.csv", dec=",", sep=";")

Note that I also used the argument sep=";" above. This way, I am assuming that the column separator in your file is the character ;. If it is a tab mark, use sep="\t".

  • worked out, thanks!

  • Whether it is a file produced in countries where decimals are marked with "," and the column separator is ";", then read.csv2 already has these values for the arguments dec and sep.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.