Using read_csv2()
I tried importing data (csv
format and ;
delimited) and automatically detect .
decimal numbers.
I have been unsuccessful so far and keep getting the following output (one can see that the last column is <chr>
rather than <num>
):
# A tibble: 46 x 4
id segment_id value_type value
<int> <int> <chr> <chr>
1 1 1 min 0
2 1 1 max 0.2
3 1 2 min 0
4 1 2 max 0.2
...
What I have tried:
1.
read_csv2("table.csv", col_types = cols())
2. I read the readr
and found out about locale()
about which the following is said
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use locale()
to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.
With the code below, however, I did not solve my problem:
read_csv2("table.csv", col_types = cols(), col_names = TRUE, locale(decimal_mark = "."))
3. After reading How to make R's read_csv2() recognise the text characters properly I tried all encondings listed in File\Save with Encoding... of RStudio to no avail:
read_csv2("table.csv", col_types = cols(), col_names = TRUE, locale(encoding = "ISO-8859-1"))
The encodings listed are: ISO-8859-1, ASCII, BIG5, GB18030, GB2312, ISO-2022-JP, ISO-2022-KR, ISO-8859-2, ISO-8859-7, SHIFT-JIS, UTF-8, WINDOWS-1252