From: Denis Chabot <chabotd_at_globetrotter.net>

Date: Tue 14 Feb 2006 - 08:07:32 EST

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 Tue Feb 14 08:13:15 2006

Date: Tue 14 Feb 2006 - 08:07:32 EST

Hi,

This is probably documented, but I cannot find the right words or expression for a search. My attempts failed.

I have a data frame of 3 vectors (x, y and z) and would like to transform this so that I could use persp. Presently I have y-level copies of each x level, and a z value for each x-y pair. I need 2 columns giving the possible levels of x and y, and then a transformation of z from a long vector into a matrix of x-level rows and y-level columns. How do I accomplish this?

In this example, I made a set of x and y values to get predictions from a GAM, then combined them with the predictions into a data frame. This is the one I'd like to transform as described above:

My.data <- expand.grid(Depth=seq(40,220, 20), Temp=seq(-1, 6, 0.5)) predgam <- predict.gam(dxt.gam, My.data, type="response") pred.data <- data.frame(My.data, predgam)

pred.data has 150 lines and 3 columns.

Thanks for your help,

Denis Chabot

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 Tue Feb 14 08:13:15 2006

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