Consider:

> f <- function(x){ x<- 10;x^2}
> f()
[1] 100

If the argument is not needed, there is no error in omitting it.
R uses "lazy evaluation" -- arguments are not evaluated until needed.

-- Bert


On Wed, Oct 5, 2011 at 8:54 AM, Scott Raynaud <scott.rayn...@yahoo.com>wrote:

> It seems I have things set up correctly.  I suspect that the arguments
> sshc(100,10) are the isuue.  It seems that the 100,10 is not necessary since
> the code itself specifies the arguments.  It runs and produces a power curve
> if I simply type sshc() but it also seems to try to keep running somethng as
> I have to click stop to get back to a prompt in the console.
>
> Why specify 100,10?  There are 9 arguments, 3 which are required and the
> rest optional.  Shouldn't I have to specify the 3 required arguments, nc, d
> and method at a minimum?  It would look like sshc(nc=500, d=.5, method=3),
> right?  I;m still not sure, however, why that would be necessary since it's
> hard coded.
>
>
> ________________________________
> From: Barry Rowlingson <b.rowling...@lancaster.ac.uk>
>
> Cc: "r-help@r-project.org" <r-help@r-project.org>
> Sent: Wednesday, October 5, 2011 9:27 AM
> Subject: Re: [R] SPlus to R
>
>
> ote:
> > Hope I did this right.  I repeated what I'd done before:
> >
> > 1) Opened script
> > 2) Selected run all (this produced my inital post
> >
> > Then as suggested I:
> >
> > 3) Typed ls()
> > 4) Saw that the function was present and issued sshc(100,10)
> >
> > Here's what I got:
> >
> >> ls()
> > [1] "c.searchd" "convex"    "Epower"    "nef"       "nef2"
> "power1.f"
> > [7] "ss.rand"   "sshc"      "vertex"
> >> sshc(100,10)
> > Error in return(ne = ne, Ep = Ep1) :
> >   multi-argument returns are not permitted
> > So it looks like I need to change the return(ne = ne, Ep = Ep1) to two
> > separate lines, correct?
> >
> > On a brighter note, I did get a power curve as expected.  One thing I
> don't
> > understand is the meaning of the arguments in sshc(100,10).
>
> There are some comments in the function code that tell you:
>
> # rc    number of response in historical control group
> # nc    sample size in historical control
> # d      target improvement = Pe - Pc
> # method 1=method based on the randomized design
> #        2=Makuch & Simon method (Makuch RW, Simon RM. Sample size
> considerations
> #          for non-randomized comparative studies. J of Chron Dis
> 1980; 3:175-181.
> #        3=uniform power method
> ######## optional Input:
>
> - and so on.
>
> Beyond that, I'll have to defer to people who know what this is
> actually trying to compute...
>
> Also, its highly possible that this code has already been ported to R
> - lots of things have. If you know what its meant to compute then a
> quick search might get you running quicker.
>
> Barry
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>
>


-- 
"Men by nature long to get on to the ultimate truths, and will often be
impatient with elementary studies or fight shy of them. If it were possible
to reach the ultimate truths without the elementary studies usually prefixed
to them, these would not be preparatory studies but superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to