Skip to content
Prev 385818 / 398503 Next

Problem with contour(): typo

On 29/09/2020 5:37 a.m., Helmut Sch?tz wrote:
>>
 >> and then plot it using contour(x, y, z, ...)

Sorry, that was a typo, should have been

   z <- outer(xs,ys, function(x,y) ...)
   contour(xs, ys, z)
I wouldn't do that, because it doesn't fit the usual R style.  It's very 
common for functions to allow vector inputs in several arguments, and 
match up corresponding values to form a vector result.
If you want to use Vectorize, the command would be

   power.TOST.vectorized <- Vectorize(power.TOST, c("theta0", "CV"))

A roughly equivalent version (without the recycling that Vectorize does) 
would be

   power.TOST.vectorized <- function(theta0, CV, ...) {
     result <- length(theta0)
     for (i in seq_along(theta0))
       result[i] <- power.TOST(theta0[i], CV[i], ...)
     result
   }

Duncan Murdoch