Re: [R] default values

2008-03-13 Thread Prof Brian Ripley
On Thu, 13 Mar 2008, Dwayne Blind wrote: > Thanks a lot. > > You were right :-) > > Professor Ripley can I use your SPLUS book for R too ? 'Modern Applied Statistics with S' and 'S Programming' both cover S and its implementations in S-PLUS and R. However, 'Modern Applied Statistics with S-PLUS

Re: [R] default values

2008-03-13 Thread Dwayne Blind
Thanks a lot. You were right :-) Professor Ripley can I use your SPLUS book for R too ? 2008/3/12, Prof Brian Ripley <[EMAIL PROTECTED]>: > > On Wed, 12 Mar 2008, Dwayne Blind wrote: > > > > Dear R users, > > > > I wrote the following toy example to explain my problem : > > > > a=0 > > f=functio

Re: [R] default values

2008-03-12 Thread Prof Brian Ripley
On Wed, 12 Mar 2008, Dwayne Blind wrote: > Dear R users, > > I wrote the following toy example to explain my problem : > > a=0 > f=function(x,y,z) { >if (a==0) x[1]+x[2]+y >if (a!=0) x[1]+x[2]+y+z > } > f(1:2,3) > > > I have not specified z and I get an error. What was the error? It work

Re: [R] default values

2008-03-12 Thread Ravi Varadhan
n.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dwayne Blind Sent: Wednesday, March 12, 2008 1:59 PM To: r-help@r-project.org Subject: [R] default values Dear R users, I wro

[R] default values

2008-03-12 Thread Dwayne Blind
Dear R users, I wrote the following toy example to explain my problem : a=0 f=function(x,y,z) { if (a==0) x[1]+x[2]+y if (a!=0) x[1]+x[2]+y+z } f(1:2,3) I have not specified z and I get an error. Although a=0, R seems to want to know z because it's in the expression x[1]+x[2]+y+z. So I