[R] Ploting a function of two arguments

From: Martin C. Martin <martin_at_metahuman.org>
Date: Fri 11 Mar 2005 - 11:52:29 EST


Hi,

I've written a function:

myfun <- function(x, y) {

   // blah blah
}

and I want to graph it. My plan is to use persp(), and my question is: how do I create the array of values? One possibility is:

x <- seq(0, 10, by=.1)
y <- seq(0, 10, by=.1)

inputs <- <somehow create an array of x,y pairs>

outputs <- apply(A, c(1,2), myfun)

The "inputs" array would need to be 101x101x2 array, i.e. basically a 2D array of pairs. I might need to write a little wrapper for myfun.

Am I on the right track, or is there an easier way to do this? It seems there should be an easier way to graph a 2 argument function like this.


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Mar 11 13:58:28 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:42 EST