Re: [R] Unreasonable syntax error

2011-06-22 Thread Greg Snow
I second the fortune nomination, probably the 1st paragraph is sufficient for a 
fortune.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Ted Harding
 Sent: Tuesday, June 21, 2011 1:25 AM
 To: r-help@r-project.org
 Subject: Re: [R] Unreasonable syntax error
 
 How long can a fortune be? Bill's response is fortune-worthy
 in its entirety!
 
 I would intensify his advice to NOT to use Microsoft Word.
 Note the Full Stop.
 
 I will spare people the full catalogue of misfortunes I have
 observed, but feel inclined to cite the case of someone to
 whom I once sent a PostScript file, who, naively, opened it
 in Word which, helpfully (as Bill emphasises), was in
 Autosave mode. Within a few seconds the file was scrambled
 beyond recovery.
 
 Best wishes to all,
 Ted.
 
 On 20-Jun-11 22:47:49, bill.venab...@csiro.au wrote:
  The advice is always NOT to use Microsoft Word to edit an R file.
  That stuff is poisonous.  Microsoft word, typical of all Microsoft
  software, does not do what you tell it to do but helpfully does
  what it thinks you meant to ask it to do but were too dumb to do so.
 
  Even notepad, gawdelpus, would be better.
 
  When I look at your script the first sign of trouble I see is:
 
  Error: unexpected input in:
   s[1,3,k]- (0.1) * runif(1)+ 0.1;
   s[1,1,k]- (0.02) *  runif(1)+ 0.98 ¨
 
  which is the spurious character Microsoft word has helpfully inserted
  to make it all look nice.  It's downhill all the way from there.
 
  (R does not expect Microsoft Word, just as nobody expects the
 Spanish
  Inquisition.  See http://www.youtube.com/watch?v=CSe38dzJYkY).
 
  Bill Venables.
 
  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of james198877
  Sent: Tuesday, 21 June 2011 7:13 AM
  To: r-help@r-project.org
  Subject: [R] Unreasonable syntax error
 
  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 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!!!
 
 
 E-Mail: (Ted Harding) ted.hard...@wlandres.net
 Fax-to-email: +44 (0)870 094 0861
 Date: 21-Jun-11   Time: 08:25:11
 -- XFMail --
 
 __
 R-help@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.

__
R-help@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.


Re: [R] Unreasonable syntax error

2011-06-21 Thread Ted Harding
How long can a fortune be? Bill's response is fortune-worthy
in its entirety!

I would intensify his advice to NOT to use Microsoft Word.
Note the Full Stop.

I will spare people the full catalogue of misfortunes I have
observed, but feel inclined to cite the case of someone to
whom I once sent a PostScript file, who, naively, opened it
in Word which, helpfully (as Bill emphasises), was in
Autosave mode. Within a few seconds the file was scrambled
beyond recovery. 

Best wishes to all,
Ted.

On 20-Jun-11 22:47:49, bill.venab...@csiro.au wrote:
 The advice is always NOT to use Microsoft Word to edit an R file.
 That stuff is poisonous.  Microsoft word, typical of all Microsoft
 software, does not do what you tell it to do but helpfully does
 what it thinks you meant to ask it to do but were too dumb to do so.
 
 Even notepad, gawdelpus, would be better.
 
 When I look at your script the first sign of trouble I see is:
 
 Error: unexpected input in:
  s[1,3,k]- (0.1) * runif(1)+ 0.1; 
  s[1,1,k]- (0.02) *  runif(1)+ 0.98 ¨
 
 which is the spurious character Microsoft word has helpfully inserted
 to make it all look nice.  It's downhill all the way from there.
 
 (R does not expect Microsoft Word, just as nobody expects the Spanish
 Inquisition.  See http://www.youtube.com/watch?v=CSe38dzJYkY).
 
 Bill Venables.
 
 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of james198877
 Sent: Tuesday, 21 June 2011 7:13 AM
 To: r-help@r-project.org
 Subject: [R] Unreasonable syntax error
 
 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 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!!!


E-Mail: (Ted Harding) ted.hard...@wlandres.net
Fax-to-email: +44 (0)870 094 0861
Date: 21-Jun-11   Time: 08:25:11
-- XFMail --

__
R-help@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.


Re: [R] Unreasonable syntax error

2011-06-21 Thread Daniel Malter
I find this sign in the code multiple times: ¨C; I replaced those with *;
there is also a MS-Word flexible hyphenation sign in there somewhere,
probably standing for a minus sign. Other than that, there are a couple of
output calls within loops that do not do anything anyway, but which seem to
be misplaced in those loops. The below code, removing those unnecessary
calls and MS symbols gives you code that runs through smoothly:

NdeTirage-1  
Longueur-40 


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
}
#
# Matrice des param?tres
para-par(NdeTirage); #para-(i,n?param?tre,n?tirage)

# Donn?es sur i (i(p,t) o? t est le num?ro de la semaine)
# p-1 - Plowed 2006 ; p-2 - Plowed 2007 ; p-3 - Unplowed 2006 ; p-4
- Unplowed 2007
i - array(1, c(4,Longueur));
i[1,1]-2;
i[1,2]-1;
i[1,3]-2;
i[1,32]-1; #p-1 - Plowed 2006  
for (m in 4:11)
i[1,m]-1;
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 * s[1,3,k];
 s[1,5,k]- (0.04) * runif(1) + 0.04;
 s[1,4,k]- (0.01)* runif(1) + 0.99 * s[1,5,k];
 s[1,7,k]- (0.26)* runif(1)+ 0.14; 
 s[1,6,k]- (0.01) * runif(1) + 0.99 * s[1,7,k];
 s[1,8,k]- (0.01)* runif(1) + 0.99; s[1,2,k]- (1.31)* runif(1) + 0.19;
 s[2,3,k]- (s[1,3,k]-max(0.8-s[1,1,k],0))*runif(1)+max(0.8-s[1,1,k],0);
 s[2,1,k]- (s[1,1,k]-(0.8-s[2,3,k]))*runif(1)+(0.8-s[2,3,k]);
 s[2,5,k]- (s[1,5,k]-max(0.4-s[1,4,k],0))*runif(1)+max(0.4-s[1,4,k],0);
 s[2,4,k]- (s[1,4,k]-(0.4-s[2,5,k]))*runif(1)+(0.4-s[2,5,k]);
 s[2,7,k]- (s[1,7,k]-max(0.7-s[1,6,k],0))*runif(1)+max(0.7-s[1,6,k],0);
 s[2,6,k]- (s[1,6,k]-(0.7-s[2,7,k]))*runif(1)+(0.7-s[2,7,k]);
 s[2,8,k]- (s[1,8,k]- 0.7)* runif(1) + 0.7;
 s[2,2,k]- s[1,2,k]* runif(1);
 s[3,3,k]- (s[2,3,k]-max(0.8-s[2,1,k],0))*runif(1)+max(0.8-s[2,1,k],0);
 s[3,1,k]- (s[2,1,k]-(0.8-s[3,3,k]))*runif(1)+(0.8-s[3,3,k]);
 s[3,5,k]- (s[2,5,k]-max(0.4-s[2,4,k],0))*runif(1)+max(0.4-s[2,4,k],0);
 s[3,4,k]- (s[2,4,k]-(0.4-s[3,5,k]))*runif(1)+(0.4-s[3,5,k]);
 s[3,7,k]- (s[2,7,k]-max(0.7-s[2,6,k],0))*runif(1)+max(0.7-s[2,6,k],0);
 s[3,6,k]- (s[2,6,k]-(0.7-s[3,7,k]))*runif(1)+(0.7-s[3,7,k]);
 s[3,8,k]- (s[2,8,k]- 0.7)* runif(1) + 0.7;
 s[3,2,k]- s[2,2,k]* runif(1);
 s[4,3,k]- (s[3,3,k]-max(0.8-s[3,1,k],0))*runif(1)+max(0.8-s[3,1,k],0);
 s[4,1,k]- (s[3,1,k]-(0.8-s[4,3,k]))*runif(1)+(0.8-s[4,3,k]);
 s[4,5,k]- (s[3,5,k]-max(0.4-s[3,4,k],0))*runif(1)+max(0.4-s[3,4,k],0);
 s[4,4,k]- (s[3,4,k]-(0.4-s[4,5,k]))*runif(1)+(0.4-s[4,5,k]);
 s[4,7,k]- (s[3,7,k]-max(0.7-s[3,6,k],0))*runif(1)+max(0.7-s[3,6,k],0);
 s[4,6,k]- (s[3,6,k]-(0.7-s[4,7,k]))*runif(1)+(0.7-s[4,7,k]);
 s[4,8,k]- (s[3,8,k]- 0.7)* runif(1) + 0.7;
 s[4,2,k]- s[3,2,k]* runif(1);  }
 s}
#
# Matrice des param?tres
para-par(NdeTirage); #para-(i,n?param?tre,n?tirage)

# Donn?es sur i (i(p,t) o? t est le num?ro de la semaine)
# p-1 - Plowed 2006 ; p-2 - Plowed 2007 ; p-3 - Unplowed 2006 ; p-4
- Unplowed 2007
i - array(1, c(4,Longueur));
i[1,1]-2;
i[1,2]-1;
i[1,3]-2;
i[1,32]-1; #p-1 - Plowed 2006  
for (m in 4:11)
i[1,m]-1;

for( m in 12:31)
i[1,m]-3;

for( m in 33:38)
i[1,m]-2;

for (m in 1:3) # p-2 -Plowed 2007
i[2,m]-2;

for (m in 30:40)
i[2,m]-2;

for (m in 4:29)
i[2,m]-1;

i[3,1]-2;
i[3,3]-2;
i[3,4]-2;
i[3,33]-2;
i[3,34]-2;
i[3,36]-2;
i[3,37]-2;
i[3,38]-2;#p-3 - Unplowed 2006
i[3,2]-1;
for (m in 5:14)
i[3,m]-1;

for (m in 15:22)
i[3,m]-3;

for (m in 23:25)
i[3,m]-1;

for (m in 26:29)
i[3,m]-3;

for (m in 30:32)
i[3,m]-1;

i[3,35]-1;

for (m in 1:3)#p-4 - Unplowed 2007
i[4,m]-2;

for (m in 4:31)
i[4,m]-1;

for (m in 32:40)
i[4,m]-2;

#

# Ecriture des autres param?tres

para2- array(0,c(4,8, NdeTirage, 40));

# On va donner les valeurs de CS et CJcs
for ( k in 1:NdeTirage){
  para2[1,6,k,1]- 0.7 *13* para[2,3,k]; para2[2,6,k,1]- 0.7 *13*
para[2,3,k]; para2[3,6,k,1]- 9.5 *13* para[2,3,k]; para2[4,6,k,1]- 9.5
*13* para[2,3,k];

for ( p in 1:4){
for (t in 1:12){
  para2[p,6,k,t+1]- para[i[p,t],1,k]*para2[p,6,k,t];
}
para2[p,5,k,13]- para[i[p,13],3,k];
for (t in 13:39){
  para2[p,5,k,t+1]- para[i[p,t+1],3,k];
  para2[p,6,k,t+1]- para[i[p,t],1,k]*para2[p,6,k,t] - para2[p,5,k,t-1]
*para2[p,6,k,t-1];}}}
#   



# On renvoie para2 (t+1) en prenant comme arguments pat- para2(t) et
rt-resultat(t)
par2 -function(t, pat, rt){
  g- array(0,c(4,8,NdeTirage));
  for ( p in 1:4){
for( k in 1:NdeTirage){
  if (t==1){
if (i[p,1]3){
  g[p,1,k]- 0;
  g[p,2,k]- 0;
}else{
  g[p,1,k]- para[i[p,1],6,k]*rt[p,k,3]+ para[i[p,1],5,k]*
rt[p,k,2];
  g[p,2,k]- para[i[p,1],8,k]*rt[p,k,4]+ para[i[p,1],7,k]*
rt[p,k,3];
}
 

[R] Unreasonable syntax error

2011-06-20 Thread james198877
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 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!!!

--
View this message in context: 
http://r.789695.n4.nabble.com/Unreasonable-syntax-error-tp3612530p3612530.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Unreasonable syntax error

2011-06-20 Thread Ray Brownrigg
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

__
R-help@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.


Re: [R] Unreasonable syntax error

2011-06-20 Thread Bill.Venables
The advice is always NOT to use Microsoft Word to edit an R file.  That stuff 
is poisonous.  Microsoft word, typical of all Microsoft software, does not do 
what you tell it to do but helpfully does what it thinks you meant to ask it to 
do but were too dumb to do so.

Even notepad, gawdelpus, would be better.

When I look at your script the first sign of trouble I see is:

Error: unexpected input in:
 s[1,3,k]- (0.1) * runif(1)+ 0.1; 
 s[1,1,k]- (0.02) *  runif(1)+ 0.98 ¨

which is the spurious character Microsoft word has helpfully inserted to make 
it all look nice.  It's downhill all the way from there.

(R does not expect Microsoft Word, just as nobody expects the Spanish 
Inquisition.  See http://www.youtube.com/watch?v=CSe38dzJYkY).

Bill Venables.

 
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of james198877
Sent: Tuesday, 21 June 2011 7:13 AM
To: r-help@r-project.org
Subject: [R] Unreasonable syntax error

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 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!!!

--
View this message in context: 
http://r.789695.n4.nabble.com/Unreasonable-syntax-error-tp3612530p3612530.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.

__
R-help@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.