[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] [FORGED] Re: paste workable code to R 4.0.0 cause error
From: Rolf Turner <r.turner () auckland ! ac ! nz>
Date: 2020-04-29 3:36:12
Message-ID: b98b419d-ec06-f736-bbe5-896614ebdf5f () auckland ! ac ! nz
[Download RAW message or body]
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 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.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic