1

I have a script in R, task.R, that reads in a .csv file, does bunch of calculations and writes a new .csv file with the final data. I'm having trouble with special characters (Icelandic), e.g. æ, á, ú etc. As an example, when I source task.R, Ára becomes ára. If I use source("task.R", encoding = "UTF-8") everything is fine.

I want to use the taskscheduleR package in R which basically source the task.R script. But because of the encoding problem, I have to create new script e.g. source_task.R with only one line of code: source("task.R", encoding = "UTF-8").
Is there any way to use the taskscheduleR package and somehow use encoding = "UTF-8" without having to create new script like source_task.R?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Viðar Ingason
  • 265
  • 3
  • 11
  • Would it help if you could modify the Icelandic characters to something more standard? There are functions like this that could be applied: ```stringi::stri_trans_general(x, "Latin-ASCII"))``` – xilliam Feb 28 '20 at 14:15
  • 1
    How do you read your csv-file in the first place? you might want to look at the `locale`-argument of the `readr::read_csv`-function. – Max Teflon Feb 28 '20 at 14:26

1 Answers1

0

You can open the R file with Notepad, and save it with ANSI encoding.

This is a ridiculous solution, but it works.

Did you happen to find any other solutions?

Zenos
  • 55
  • 1
  • 4