Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error? Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
error in calling source(): invalid multibyte character in parser
7 messages · Phil Spector, Peter Dalgaard, Brian Ripley +1 more
Luca -
What happens why you type
Sys.setlocale('LC_ALL','C')
before issuing the source command?
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Mon, 3 Jan 2011, Luca Meyer wrote:
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error? Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
______________________________________________ R-help at r-project.org mailing list 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.
On Jan 3, 2011, at 08:32 , Luca Meyer wrote:
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error?
The most likely cause is that your scripts are written in an "8 bit ASCII" encoding (Latin-1 or -9, most likely), while R is running in a UTF8 locale. If that is the cause, the fix is to standardize things to use the same locale. You can convert the encoding of your source file using the iconv utility (in a Terminal window). -pd
Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
______________________________________________ R-help at r-project.org mailing list 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.
Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
On Mon, 3 Jan 2011, peter dalgaard wrote:
On Jan 3, 2011, at 08:32 , Luca Meyer wrote:
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error?
The most likely cause is that your scripts are written in an "8 bit ASCII" encoding (Latin-1 or -9, most likely), while R is running in a UTF8 locale. If that is the cause, the fix is to standardize things to use the same locale. You can convert the encoding of your source file using the iconv utility (in a Terminal window).
Or use the 'encoding' argument of source() to tell R what the encoding is, e.g. encoding="latin1" or "latin-9" (the inconsistency being in the iconv used on Macs, not in R).
-pd
Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
______________________________________________ R-help at r-project.org mailing list 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.
-- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
______________________________________________ R-help at r-project.org mailing list 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.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
1 day later
It works fine, thanks. I was just wondering is there is anyway to include automatically the command you suggest as a default when I open R. Thanks, Luca Il giorno 03/gen/2011, alle ore 08.36, Phil Spector ha scritto:
Luca -
What happens why you type
Sys.setlocale('LC_ALL','C')
before issuing the source command?
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Mon, 3 Jan 2011, Luca Meyer wrote:
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error? Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
______________________________________________ R-help at r-project.org mailing list 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.
How would I go by doing that? I have tried with:
source("file.R", encoding="it_IT.UTF-8")
But I get
Error in file(file, "r", encoding = encoding) :
unsupported conversion from 'it_IT.UTF-8' to ''
Thanks,
Luca
PS: "it_IT.UTF-8" is what I get under locale when I run sessionInfo()
Il giorno 03/gen/2011, alle ore 09.48, Prof Brian Ripley ha scritto:
On Mon, 3 Jan 2011, peter dalgaard wrote:
On Jan 3, 2011, at 08:32 , Luca Meyer wrote:
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error?
The most likely cause is that your scripts are written in an "8 bit ASCII" encoding (Latin-1 or -9, most likely), while R is running in a UTF8 locale. If that is the cause, the fix is to standardize things to use the same locale. You can convert the encoding of your source file using the iconv utility (in a Terminal window).
Or use the 'encoding' argument of source() to tell R what the encoding is, e.g. encoding="latin1" or "latin-9" (the inconsistency being in the iconv used on Macs, not in R).
-pd
Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
______________________________________________ R-help at r-project.org mailing list 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.
-- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
______________________________________________ R-help at r-project.org mailing list 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.
-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Tue, 4 Jan 2011, Luca Meyer wrote:
How would I go by doing that? I have tried with:
source("file.R", encoding="it_IT.UTF-8")
But I get
Error in file(file, "r", encoding = encoding) :
unsupported conversion from 'it_IT.UTF-8' to ''
Well, that is not the value I suggested -- so what not simply follow what you were asked to try?
Thanks, Luca PS: "it_IT.UTF-8" is what I get under locale when I run sessionInfo() Il giorno 03/gen/2011, alle ore 09.48, Prof Brian Ripley ha scritto:
On Mon, 3 Jan 2011, peter dalgaard wrote:
On Jan 3, 2011, at 08:32 , Luca Meyer wrote:
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying: invalid multibyte character in parser I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case. Can anyone suggest a fix for this error?
The most likely cause is that your scripts are written in an "8 bit ASCII" encoding (Latin-1 or -9, most likely), while R is running in a UTF8 locale. If that is the cause, the fix is to standardize things to use the same locale. You can convert the encoding of your source file using the iconv utility (in a Terminal window).
Or use the 'encoding' argument of source() to tell R what the encoding is, e.g. encoding="latin1" or "latin-9" (the inconsistency being in the iconv used on Macs, not in R).
-pd
Thanks, Luca Mr. Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.1 (2010-12-16) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
______________________________________________ R-help at r-project.org mailing list 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.
-- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
______________________________________________ R-help at r-project.org mailing list 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.
-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595