5

I want to use readr::parse_number() for a character vector that was guessed as type "number" by readr::guess_parser()

I can construct a locale to make this work using readr::parse_number( readr::locale(decimal_mark = <a mark to be determined at run time>) )

So the issue is the system locale is unknown until runtime and could be anywhere in the world. Is there a way to determine the decimal mark from the system locale?

MilesMcBain
  • 1,115
  • 10
  • 12
  • I think Sys.localeconv() could end up helping although it wont be pretty. – MilesMcBain Mar 07 '17 at 03:01
  • 2
    I might just use a line like `dec <- gsub("\\d", "", 0.1)` to pull the decimal mark from the output since the decimal mark of the current locale will print in the output – Rich Scriven Mar 07 '17 at 03:23
  • I've done some testing with the help of a colleague in Spain. I don't think this will work. It seems like the decimal mark for the locale is always "." in R. This makes sense because If you change it, it gives a warning about R not working as expected. The currency decimal`mon_decimal_point` seems to be set correctly. Maybe I can use this. – MilesMcBain Mar 07 '17 at 11:39

0 Answers0