On 2020/4/29 11:55, Richard M. Heiberger wrote:
I pasted it into Emacs ESS on Macintosh, Emacs ESS on Windows, and Rgui
on Windows.
All 4.0.0 . It runs fine.
I test the code using ESS on Windows. It also give error, but with
different position:
> gz <- within(gz,
+ {
+ a <- x1 #a中中中中中中中
Error: invalid multibyte character in parser at line 4
Is it related with locale?
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936
[2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.0 tools_4.0.0
On Tue, Apr 28, 2020 at 11:36 PM Rolf Turner <r.tur...@auckland.ac.nz
<mailto:r.tur...@auckland.ac.nz>> wrote:
The (excellent) MWE that you provided runs just fine for me (in R 4.0.0
under Ubuntu 18.04) either by sourcing "aaa.R" or by using
copy-and-paste.
Must be Windoze thing. Switch to Linux!
cheers,
Rolf Turner
n 29/04/20 2:25 pm, Jinsong Zhao wrote:
> On 2020/4/29 8:05, Jinsong Zhao wrote:
>> Hi there,
>>
>> I have a piece of source code with some inline comments in
Chinese. It
>> works well when I copy it from a editor (gvim here), and paste
it to
>> Rgui console on R 3.6.3, however, when I do the same thing, R 4.0.0
>> give error message:
>>
>> Error: invalid multibyte character in parser at line 21
>>
>> If I source() the code from Rgui console, it can run without any
error.
>>
>> Any hints?
>>
>> BTW, I do not make a minimal workable example yet.
>>
>
> Here is the MWE:
>
> D:\system\Desktop>cat aaa.R
> gz <- data.frame(x1 = rnorm(100), x10 = rnorm(100))
> gz <- within(gz,
> {
> a <- x1 #a中中中中中中中
> bbbbb <- x10 #b中中中a中中中中
> ccccc <- x10 #c中中中中中中中中
> ddddd <- x10 #d中中中中中b中中中中
> eeeee <- x10 #e中中中中中中中中
> fffff <- x10 #f中中中中中c
> })
>
> The ASCII character in the code could be replace by other ASCII
> character. The Chinese character could be replace by other Chinese
> character.
>
> Calling source("aaa.R") could run normally. If you select all the
code
> and paste it to Rgui console, it will give error:
>
> > gz <- data.frame(x1 = rnorm(100), x10 = rnorm(100))
> > gz <- within(gz,
> + {
> + a <- x1 #a中中中中中中中
> + bbbbb <- x10 #b中中中a中中中中
> + ccccc <- x10 #c中中中中中中中中
> + ddddd <- x10 #d中中中中中b中中中中
> + eeeee <- x10 #e中中中中中中中中
> + fffff <- x10 #f中中中中中c
> Error: invalid multibyte character in parser at line 9
> > })
> Error: unexpected '}' in " }"
> >
>
> If you delete any character from the comment, or add any
character to
> the comment. The code can paste to the console without any error.
>
> If you change the length of `bbbbb`...`fffff`, the code also
could be
> paste and run without any error.
>
> Best,
> Jinsong
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
______________________________________________
R-help@r-project.org <mailto: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.
______________________________________________
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.