Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Decimal read in does not change

I try to read in a .csv file with, example, such a column:

img

These values are meant like they are representing thousands of hours, not two or three hours and so on.
When I try to change the reading in options through

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

read.csv(file, sep = ";, dec = ".") nothing changes. It doesn’t matter what I define, dec = "." or dec = "," it will always keep these numbers above.

>Solution :

You can use the following code:

library(readr)
df <- read_csv('data.csv', locale = locale(grouping_mark = "."))
df

Output:

# A tibble: 4 × 1
  `X-ray`
    <dbl>
1    2771
2    3783
3    1267
4    7798

As you can see, the values are now thousands.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading