Re: [R] Can't get sample function from An Introduction to R to work

2005-07-16 Thread Spencer Graves
  When you copied it into MS Word, did you Copy - paste special - 
unformatted text?  This trick sometimes might expose (or eliminate) 
nonprinting characters or characters with special attributes that might 
have created the problem.

  spencer graves

David Groos wrote:

 Thank you-all very much for your help, your responses and help has been 
 very encouraging.  The following doesn't close the case but it tables 
 it...
 
 First I copied Ken's code into my R Console and...it worked great!  
 That was baffling as it looked identical to mine.
 
 I did not explicitly say earlier that the code I sent out I had copied 
 from the console, pasted into MS Word, changed font size, then pasted 
 it into the e-mail--in other words, that was a copy of one of the codes 
 that didn't work.
 
 Anyway,  I then copied the non-working, pasted it into Console, 
 expecting that it would say Error: syntax error upon pressing the 
 return key at the end of this line:
 
+ tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
 
 but it didn't!  and the code worked this time, also!
 I then went about doing what I could to replicate the error from before 
 and was as unsuccessful in doing that as I was in making it work, 
 earlier.
 
 
 On Jul 15, 2005, at 4:43 PM, Peter Dalgaard wrote:
 
 
Bret Collier [EMAIL PROTECTED] writes:


David,
If below is exactly what you typed, check your code again, I think you
are missing a '}' after the last 2 parentheses.

That's not supposed to cause a syntax error, just another '+'.
 
 (right! that's what I thought...)
 
I can copy and paste the code as written and not get an error:


twosam-function(y1, y2) {

+ n1-length(y1);n2 -length(y2)
+ yb1-mean(y1); yb2-mean(y2)
+ s1-var(y1);s2-var(y2)
+ s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
+ tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
+ }

Perhaps this was the 1st time David got his typing right? The error is
of the sort you'd get if you had

 s-((n1-1)*s1 + (n2-1)*s2/(n1+n2-2)
 
 Interestingly enough, I did try this line when first I was trying to 
 make the code work and with just 1 ) at the end I didn't get the 
 error message, but then again I wasn't able to make the whole program 
 work, either.
 
 In conclusion, I can't explain why it didn't first work time nor why I 
 couldn't replicate the error.  I think I ought to e-mail the Mac R 
 folks about this.
 
 Again, Thanks,
 
 -David
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-16 Thread Thomas Lumley
On Fri, 15 Jul 2005, David Groos wrote:

 Thank you-all very much for your help, your responses and help has been
 very encouraging.  The following doesn't close the case but it tables
 it...

 First I copied Ken's code into my R Console and...it worked great!
 That was baffling as it looked identical to mine.

 I did not explicitly say earlier that the code I sent out I had copied
 from the console, pasted into MS Word, changed font size, then pasted
 it into the e-mail--in other words, that was a copy of one of the codes
 that didn't work.


Mysterious syntax errors on OS X can result from copying and pasting into 
R. Files that look perfectly innocent can contain Windows line endings 
(\r\n) or en-dashes instead of hyphens.  These might well be transparently 
fixed in the process of converting to email.

If you actually typed into the R console then this won't explain it, of 
course.

-thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-16 Thread David Groos

On Jul 16, 2005, at 9:58 AM, Thomas Lumley wrote:

 On Fri, 15 Jul 2005, David Groos wrote:

 Thank you-all very much for your help, your responses and help has 
 been
 very encouraging.  The following doesn't close the case but it tables
 it...

 First I copied Ken's code into my R Console and...it worked great!
 That was baffling as it looked identical to mine.

 I did not explicitly say earlier that the code I sent out I had copied
 from the console, pasted into MS Word, changed font size, then pasted
 it into the e-mail--in other words, that was a copy of one of the 
 codes
 that didn't work.


 Mysterious syntax errors on OS X can result from copying and pasting 
 into R. Files that look perfectly innocent can contain Windows line 
 endings (\r\n) or en-dashes instead of hyphens.  These might well be 
 transparently fixed in the process of converting to email.
I'll put this, as well as the copying/pasting as unformatted text as 
recommends Spencer, into my bag of tricks.

 If you actually typed into the R console then this won't explain it, 
 of course.
And indeed, I did type right into the R console, so the mystery 
remains...
Thanks,
David

   -thomas


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-15 Thread Bret Collier
David,
If below is exactly what you typed, check your code again, I think you
are missing a '}' after the last 2 parentheses.

HTH,
Bret

 David Groos [EMAIL PROTECTED] 7/15/2005 3:40:01 PM 
I'm trying to figure out R, a piece at a time, hours at a time...  I 
was trying to copy the sample function in, An Introduction to R  (for

version 2.1.0) by W. N. Venables, D. M. Smith, page 42.  Section 10.1 
Simple examples provides a sample function which I tried to duplicate

(I'm using Mac OS X 10.3.9, and R for Mac OS X Aqua GUI v1.11).  The 
following is what I typed and the last line is R's response when I hit

the return key after the penultimate line.  I've re-checked and 
re-typed the code many times to no avail.  I wasn't able to find this 
issue using search options, either.  Any help is GREATLY appreciated!

  twosam-function(y1, y2) {
+ n1-length(y1);n2 -length(y2)
+ yb1-mean(y1); yb2-mean(y2)
+ s1-var(y1);s2-var(y2)
+ s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
+ tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
Error: syntax error

David
[[alternative text/enriched version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-15 Thread Marc Schwartz (via MN)
On Fri, 2005-07-15 at 15:40 -0500, David Groos wrote:
 I'm trying to figure out R, a piece at a time, hours at a time...  I 
 was trying to copy the sample function in, An Introduction to R  (for 
 version 2.1.0) by W. N. Venables, D. M. Smith, page 42.  Section 10.1 
 Simple examples provides a sample function which I tried to duplicate 
 (I'm using Mac OS X 10.3.9, and R for Mac OS X Aqua GUI v1.11).  The 
 following is what I typed and the last line is R's response when I hit 
 the return key after the penultimate line.  I've re-checked and 
 re-typed the code many times to no avail.  I wasn't able to find this 
 issue using search options, either.  Any help is GREATLY appreciated!
 
   twosam-function(y1, y2) {
 + n1-length(y1);n2 -length(y2)
 + yb1-mean(y1); yb2-mean(y2)
 + s1-var(y1);s2-var(y2)
 + s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
 + tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
 Error: syntax error
 
 David

The code as you have above (without the + on each line) works for me
both in ESS and in the R console under Linux. There should be another
+ on the next line, in anticipation of the remaining two lines:

 tst
}


Try to copy and paste the following into the console as is:

twosam-function(y1, y2) {
 n1 - length(y1);n2 - length(y2)
 yb1 - mean(y1); yb2 - mean(y2)
 s1 - var(y1);s2 - var(y2)
 s - ((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
 tst - (yb1-yb2)/sqrt(s*(1/n1+1/n2))

and see what happens. You should be left at a:

+

on a new line again.

It is possible that there is a bug in the Aqua GUI, but not using a Mac,
I cannot replicate it.

You might want to consider subscribing and posting to the R-SIG-Mac
e-mail list, which is focused on Mac users of R. More information is
here:

https://stat.ethz.ch/mailman/listinfo/r-sig-mac

HTH,

Marc Schwartz

P.S. Greetings from Eden Prairie

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-15 Thread Spencer Graves
  Also, are you doing this with a version of R that will allow you to 
keep your scripts in separate files and run them one line at a time? 
Rgui allows this, and many people use different editors, e.g, XEmacs 
with ESS (EMacs Speaks Statistics).  Some editors (like ESS) help with 
parentheses matching, which makes it easier to catch errors like this. 
When that fails, I define the necessary variables and work through the 
function line by line until I find the problem.

  spencer graves

Bret Collier wrote:

 David,
 If below is exactly what you typed, check your code again, I think you
 are missing a '}' after the last 2 parentheses.
 
 HTH,
 Bret
 
 
David Groos [EMAIL PROTECTED] 7/15/2005 3:40:01 PM 
 
 I'm trying to figure out R, a piece at a time, hours at a time...  I 
 was trying to copy the sample function in, An Introduction to R  (for
 
 version 2.1.0) by W. N. Venables, D. M. Smith, page 42.  Section 10.1 
 Simple examples provides a sample function which I tried to duplicate
 
 (I'm using Mac OS X 10.3.9, and R for Mac OS X Aqua GUI v1.11).  The 
 following is what I typed and the last line is R's response when I hit
 
 the return key after the penultimate line.  I've re-checked and 
 re-typed the code many times to no avail.  I wasn't able to find this 
 issue using search options, either.  Any help is GREATLY appreciated!
 
   twosam-function(y1, y2) {
 + n1-length(y1);n2 -length(y2)
 + yb1-mean(y1); yb2-mean(y2)
 + s1-var(y1);s2-var(y2)
 + s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
 + tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
 Error: syntax error
 
 David
   [[alternative text/enriched version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help 
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-15 Thread Peter Dalgaard
Bret Collier [EMAIL PROTECTED] writes:

 David,
 If below is exactly what you typed, check your code again, I think you
 are missing a '}' after the last 2 parentheses.

That's not supposed to cause a syntax error, just another '+'.
I can copy and paste the code as written and not get an error:

 twosam-function(y1, y2) {
+ n1-length(y1);n2 -length(y2)
+ yb1-mean(y1); yb2-mean(y2)
+ s1-var(y1);s2-var(y2)
+ s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
+ tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
+ }


Perhaps this was the 1st time David got his typing right? The error is
of the sort you'd get if you had 

 s-((n1-1)*s1 + (n2-1)*s2/(n1+n2-2)

or

 tst-(yb1-yb2)/sqrt(s*1/n1+1/n2))

 
 HTH,
 Bret
 
  David Groos [EMAIL PROTECTED] 7/15/2005 3:40:01 PM 
 I'm trying to figure out R, a piece at a time, hours at a time...  I 
 was trying to copy the sample function in, An Introduction to R  (for
 
 version 2.1.0) by W. N. Venables, D. M. Smith, page 42.  Section 10.1 
 Simple examples provides a sample function which I tried to duplicate
 
 (I'm using Mac OS X 10.3.9, and R for Mac OS X Aqua GUI v1.11).  The 
 following is what I typed and the last line is R's response when I hit
 
 the return key after the penultimate line.  I've re-checked and 
 re-typed the code many times to no avail.  I wasn't able to find this 
 issue using search options, either.  Any help is GREATLY appreciated!
 
   twosam-function(y1, y2) {
 + n1-length(y1);n2 -length(y2)
 + yb1-mean(y1); yb2-mean(y2)
 + s1-var(y1);s2-var(y2)
 + s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
 + tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
 Error: syntax error
 


-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can't get sample function from An Introduction to R to work

2005-07-15 Thread David Groos
Thank you-all very much for your help, your responses and help has been 
very encouraging.  The following doesn't close the case but it tables 
it...

First I copied Ken's code into my R Console and...it worked great!  
That was baffling as it looked identical to mine.

I did not explicitly say earlier that the code I sent out I had copied 
from the console, pasted into MS Word, changed font size, then pasted 
it into the e-mail--in other words, that was a copy of one of the codes 
that didn't work.

Anyway,  I then copied the non-working, pasted it into Console, 
expecting that it would say Error: syntax error upon pressing the 
return key at the end of this line:
 + tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
but it didn't!  and the code worked this time, also!
I then went about doing what I could to replicate the error from before 
and was as unsuccessful in doing that as I was in making it work, 
earlier.


On Jul 15, 2005, at 4:43 PM, Peter Dalgaard wrote:

 Bret Collier [EMAIL PROTECTED] writes:

 David,
 If below is exactly what you typed, check your code again, I think you
 are missing a '}' after the last 2 parentheses.

 That's not supposed to cause a syntax error, just another '+'.
(right! that's what I thought...)
 I can copy and paste the code as written and not get an error:

 twosam-function(y1, y2) {
 + n1-length(y1);n2 -length(y2)
 + yb1-mean(y1); yb2-mean(y2)
 + s1-var(y1);s2-var(y2)
 + s-((n1-1)*s1 + (n2-1)*s2)/(n1+n2-2)
 + tst-(yb1-yb2)/sqrt(s*(1/n1+1/n2))
 + }


 Perhaps this was the 1st time David got his typing right? The error is
 of the sort you'd get if you had

  s-((n1-1)*s1 + (n2-1)*s2/(n1+n2-2)
Interestingly enough, I did try this line when first I was trying to 
make the code work and with just 1 ) at the end I didn't get the 
error message, but then again I wasn't able to make the whole program 
work, either.

In conclusion, I can't explain why it didn't first work time nor why I 
couldn't replicate the error.  I think I ought to e-mail the Mac R 
folks about this.

Again, Thanks,

-David

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html