If you're running it from Rscript, you'll have to specify the encoding like this:
Rscript --encoding UTF-8 file If you're using R for Windows, I'm surprised this issue would come up since R 4.2.0 added support for UTF-8. At least on my own Windows machine, I can run exactly what you wrote and not have any issues. Are you using an older version of R? On Wed., Sep. 21, 2022, 14:20 Andrew Hart via R-help, <r-help@r-project.org> wrote: > On 21/09/2022 11:46, Bert Gunter wrote: > > ?options > > > > options(encoding = "utf-8") > > in a startup file or function should presumably do it. See ?Startup > > > > Bert > > Thanks everyone. Setting encoding in options in Rprofile.site has taken > care of it. > > Curiously, it doesn't seem to solve the whole problem for Rscript > though. I checked that Rscript is indeed picking up the default encoding > from options, but it's complaining about seeing an unexpected input in > dat$lĂnea <- .... > immediately following the l when I run > Rscript myfile.R. > So, it would appear that Rscript is not using source to read in the R > script. Mind you, if I do > Rscript -e source('myfile.R') > it works properly just like in Rgui. > > Once again, Thanks heaps. > > Cheers, > Andrew. > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.