[R] Beginner plot and map questions

vincent@7d4.com vincent at 7d4.com
Sat Oct 15 05:08:54 CEST 2005


Web User a écrit :

> 1.) Is there a way to convert a table (e.g. represented as a data frame) 
> to a function, specifying which columns are input and which column is 
> output?  It would seem that this would be useful for plotting 
> experimental results, since e.g. contour(x, y, f) requires f to be a 
> function.

I think on something rather ugly.
Hopefully somebody will propose a more elegant solution.

1/ store your data in a global array myexpresults[,]
2/ define f(x,y) as
f function(x,y) {return(myexpresults[x,y]);};

x,y are integers and f is discrete in the above case.
But if you want to allow x,y continuous,
you can also interpolate in f() with the grid results
the nearest from (x,y).

You can also do it without a global, by reading your table directly
in f(), but this will demand to reread the table each time f is called
which may be rather impracticable.




More information about the R-help mailing list