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

Spencer Graves spencer.graves at pdf.com
Fri Jul 15 23:12:07 CEST 2005


	  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 <david.groos at mpls.k12.mn.us> 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 at 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 at 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

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list