Re: [R] How to set default encoding for sourced files

2022-09-23 Thread Andrew Hart via R-help
Thanks. The --encoding option indeed makes it all work. Rscript --help does not show the --encoding option in the list of options. And yes, you are right. I was using R 4.1.2 when I first wrote to the list. I was experiencing a technical issue with R 4.2.1 which was preventing me from switchi

Re: [R] How to set default encoding for sourced files

2022-09-21 Thread Andrew Simmons
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

Re: [R] How to set default encoding for sourced files

2022-09-21 Thread Andrew Hart via R-help
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 fo

Re: [R] How to set default encoding for sourced files

2022-09-21 Thread Bert Gunter
?options options(encoding = "utf-8") in a startup file or function should presumably do it. See ?Startup Bert On Wed, Sep 21, 2022 at 7:34 AM Andrew Hart via R-help wrote: > Hi there. I'm working with some utf-8 incoded csv files which gives me > data frames with utf-8 encoded headers. This me

Re: [R] How to set default encoding for sourced files

2022-09-21 Thread Eric Berger
Hi Andrew, If you look at ?source you see its default value for encoding is picked up from getOption("encoding"). Couldn't you just set this option in your Rprofile? HTH, Eric On Wed, Sep 21, 2022 at 5:34 PM Andrew Hart via R-help wrote: > > Hi there. I'm working with some utf-8 incoded csv fil

[R] How to set default encoding for sourced files

2022-09-21 Thread Andrew Hart via R-help
Hi there. I'm working with some utf-8 incoded csv files which gives me data frames with utf-8 encoded headers. This means when I write things like dat$proporciĆ³n in an R script and then source it, I have to make sure the R script is incoded using utf-8 (and not latin1) and then I also have to ex