[R] Function not returning a vector?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Aug 28 20:46:56 CEST 2008


2008/8/28  <rkevinburton at charter.net>:

> hazard <- function(x,shape,scale)
> {
>   return (shape/scale) * (x/scale)^(shape - 1)
> }
>
> Only return a single value? It is like x becomes a single value passed as an argument.
>

 It's evaluating return(shape/scale) and returning that! Add some
extra parentheses:

 return( (shape/scale) * (x/scale)^(shape-1) )

 seems to work. Are you a python programmer, perhaps?

Barry



More information about the R-help mailing list