[R] Reshape package: Casting data to form a grid
Steve Murray
smurray444 at hotmail.com
Mon Aug 17 18:52:47 CEST 2009
Dear R Users,
I'm trying to use the 'cast' function in the 'reshape' package to convert column-format data to gridded-format data. A sample of my dataset is as follows:
head(finalframe)
Latitude Longitude Temperature OrigLat p-value Blaney
1 -90 -38.75 NA -87.75 17.10167 NA
2 -90 135.75 NA -87.75 17.10167 NA
3 -90 80.25 NA -87.75 17.10167 NA
4 -90 95.75 NA -87.75 17.10167 NA
5 -90 66.75 NA -87.75 17.10167 NA
6 -90 75.75 NA -87.75 17.10167 NA
I'm attempting to form a grid based on the OrigLat, Longitude and Blaney columns, to form the rows, columns and values of the new grid respectively.
The command I've been using is:
cast_test <- cast(finalframe, finalframe$OrigLat~variable, finalframe$Longitude~variable, finalframe$Blaney~variable)
Error: Casting formula contains variables not found in molten data: finalframe$OrigLat, variable
And I've tried removing the ~variable suffixes:
cast_test <- cast(finalframe, finalframe$OrigLat, finalframe$Longitude, finalframe$Blaney)
Error: Casting formula contains variables not found in molten data: -87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75 [etc etc]
I'm not sure how to get round this error, nor what the 'molten data' is that the error is referring to. I'm assuming it means the data frame presented above, yet the variables are clearly present!
Any help or advice on this would be most welcomed.
Many thanks,
Steve
_________________________________________________________________
[[elided Hotmail spam]]
More information about the R-help
mailing list