Thanks.  I only use R on occasion, but I knew I could work around it easily 
(and in fact some other users were nice enough to send some code).  

When it only worked when inputting n, I thought it might be just an accident, 
but thought I would ask.

Thanks for the explanation.

Best,

Steve


On Oct 1, 2014, at 6:46 PM, peter dalgaard <pda...@gmail.com> wrote:


On 01 Oct 2014, at 14:29 , Stephen Kennedy <step...@prollenium.com> wrote:

> Simple question.  A vector of ‘number of observations’ can be input to 
> power.t.test, and a vector of ‘power’ s is output.  But, inputting a vector 
> of powers generates an error.  Am I missing something?

Power.t.test was written for scalar arguments. If it happens to work with 
vector arguments, it is entirely coincidental. The essence of what you observe 
is that power is calculated by pt() which vectorizes, but n is calculated by 
numerical solution using uniroot() which does not vectorize. 

If you need a vectorized version, check out Vectorize().

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd....@cbs.dk  Priv: pda...@gmail.com

______________________________________________
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