[R] Unreasonable syntax error
Ray Brownrigg
Ray.Brownrigg at ecs.vuw.ac.nz
Tue Jun 21 00:46:05 CEST 2011
On Tue, 21 Jun 2011, james198877 wrote:
> http://r.789695.n4.nabble.com/file/n3612530/PSC.r PSC.r
>
> Hi all,
>
> I just wrote a program in R by editing it in Microsoft Word and then
> pasting into the text editor of R. The above is the file.
>
> And below is what the console complains.... Why doesn't it recognise 'r'??
I don't see 'r' at all. It doesn't recognise s.
You have strange (16-bit?) characters in your .r file.
Note in your output:
NdeTirage<-1 # NdeTirage d?signe le nombre de tirages
> Longueur<-40 # L'exp?rience s'?tale sur 40 semaines
>
> # Ecriture de la matrice des param?tres
> par<-function(N){
+ s<- array(0,c(4,8,N));
+ for( k in 1:N){
+ s[1,3,k]<- (0.1) * runif(1)+ 0.1;
+ s[1,1,k]<- (0.02) * runif(1)+ 0.98 ¨C s[1,3,k];
^^
> s[1,5,k]<- (0.04) * runif(1) + 0.04;
Error in s[1, 5, k] <- (0.04) * runif(1) + 0.04 : object 's' not found
The "¨C" (which I guess is a 'dash' rather than a 'minus') is not recognised, and seems
to 'complete' the function definition (the "+'s stop appearing in column 1), but s is only
defined inside the function.
>
> I have to mention that at least when I typed this first several lines into
> the console, the first error didn't appear. I don't try the next errors as
> there would be too many lines to type...I'm not sure if this is something
> about Word
>
> http://r.789695.n4.nabble.com/file/n3612530/lastsave.txt lastsave.txt
>
> Thanks a lot for your help!!!
>
Why use Word for a text file when Notepad would do the job (better)?
Ray Brownrigg
More information about the R-help
mailing list