Re: [R] Trap an error from a function

2012-09-18 Thread William Dunlap
Winsemius > Sent: Tuesday, September 18, 2012 5:35 PM > To: John Sorkin > Cc: r-help@r-project.org > Subject: Re: [R] Trap an error from a function > > > On Sep 18, 2012, at 5:10 PM, John Sorkin wrote: > > > Window 7 > > R 2.15 > > > > I am writing a s

Re: [R] Trap an error from a function

2012-09-18 Thread Thomas Lumley
On Wed, Sep 19, 2012 at 12:56 PM, David Winsemius wrote: > Basically you run you each iteration of your code inside try() and then test > to see if it's class vector includes "try-error", ... then you can do > something with the result or return NA. This may makeit more useful because I > retur

Re: [R] Trap an error from a function

2012-09-18 Thread Peter Langfelder
On Tue, Sep 18, 2012 at 5:35 PM, David Winsemius wrote: > > On Sep 18, 2012, at 5:10 PM, John Sorkin wrote: > >> Window 7 >> R 2.15 >> >> I am writing a simulation which generates sample sized estimates from >> simulated data. When I run the function shown below, >> power.t.test(delta=14.02528,sd

Re: [R] Trap an error from a function

2012-09-18 Thread David Winsemius
Basically you run you each iteration of your code inside try() and then test to see if it's class vector includes "try-error", ... then you can do something with the result or return NA. This may makeit more useful because I return the results at each iteration if there was no error: sapply(tes

Re: [R] Trap an error from a function

2012-09-18 Thread John Sorkin
David, Thank you. I will study your code so I can understand your suggestion. Thanks, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Bal

Re: [R] Trap an error from a function

2012-09-18 Thread David Winsemius
On Sep 18, 2012, at 5:10 PM, John Sorkin wrote: > Window 7 > R 2.15 > > I am writing a simulation which generates sample sized estimates from > simulated data. When I run the function shown below, > power.t.test(delta=14.02528,sd=1.945226,power=0.8,sig.level=0.05) > > I get an error message: >

Re: [R] Trap an error from a function

2012-09-18 Thread Duncan Murdoch
On 12-09-18 8:10 PM, John Sorkin wrote: Window 7 R 2.15 I am writing a simulation which generates sample sized estimates from simulated data. When I run the function shown below, power.t.test(delta=14.02528,sd=1.945226,power=0.8,sig.level=0.05) I get an error message: power.t.test(delta=14.0

[R] Trap an error from a function

2012-09-18 Thread John Sorkin
Window 7 R 2.15 I am writing a simulation which generates sample sized estimates from simulated data. When I run the function shown below, power.t.test(delta=14.02528,sd=1.945226,power=0.8,sig.level=0.05) I get an error message: > power.t.test(delta=14.02528,sd=1.945226,power=0.8,sig.level=0