On 10/05/2011 07:44 AM, Scott Raynaud wrote:
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?

As another poster suggested, use list(ne = ne, Ep = Ep1) instead of the the present return().

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

Thanks agian for your help.


________________________________ From: Barry
Rowlingson<b.rowling...@lancaster.ac.uk>

Cc: "r-help@r-project.org"<r-help@r-project.org> Sent: Wednesday,
October 5, 2011 4:02 AM Subject: Re: [R] SPlus to R


te:
I'm trying to convert an S-Plus program to R.  Since I'm a SAS
programmer I'm not facile is either S-Plus or R, so I need some
help.  All I did was convert the underscores in S-Plus to the
assignment operator<-.  Here are the first few lines of the S-Plus
file:

sshc _ function(rc, nc, d, method, alpha=0.05, power=0.8, tol=0.01,
tol1=.0001, tol2=.005, cc=c(.1,2), l.span=.5) { ### for method 1 if
(method==1) { ne1 _ ss.rand(rc,nc,d,alpha=.05,power=.8,tol=.01)
return(ne=ne1) }


My translation looks like this:

sshc<-function(rc, nc=500, d=.5, method=3, alpha=0.05, power=0.8,
tol=0.01, tol1=.0001, tol2=.005, cc=c(.1,2), l.span=.5) { ### for
method 1 if (method==1) {
ne1<-ss.rand(rc,nc,d,alpha=.05,power=.8,tol=.01) return(ne=ne1) }

The program runs without throwing errors, but I'm not getting any
ourput in the console.  This is where it should be, right?  I think
I have this set up correctly.  I'm using method=3 which only
requires nc and d to be specified.  Any ideas why I'm not seeing
output?

Long shot: the code you posted looked like (and hard to tell without
indentation) just a bunch of function definitions. R won't actually
do anything unless you call those functions with some parameters.

So, when you say you get no output when you 'run' the code, what
exactly do you mean by 'run' the code? What I would do is:

1. Put the code in a file called 'whatever.R'. 2. Start R, and do
source("whatever.R"). That defines the functions. do "ls()" and you
should see them. 3. Call one of the functions: sshc(100,10)

I'd call that, in R terms, "calling the sshc function" rather than
running anything.

Barry


--
Kevin E. Thorpe
Biostatistician/Trialist,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

______________________________________________
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