Hi Nikki,
I'm myself not an expert in dealing with factors, so my approach would
be to coerce the factor-column to character with
yourgrid$factor_column <- as.character(yourgrid$factor_column)
then perform the substitutions as in the meuse.grid example and coerce
back to factor if needed with
yourgrid$factor_column <- factor(yourgrid$factor_column)
Maybe somebody else on the list has a cleaner/more efficient way do deal
with this?
regards,
Tom
Am 20.02.2011 14:57, schrieb Nikki roy:
Hi Tom,
What you said here works for numbers datatype but my data type is factor
(levels). i am still very new to R. Please help.
library(sp)
data(meuse.grid)# "data.frame"
coordinates(meuse.grid)<- ~x+y
meuse.grid<- as(as(meuse.grid,
"SpatialPixelsDataFrame"),"SpatialGridDataFrame")#"SpatialGridDataFrame"
spplot(meuse.grid[,,"soil"])
meuse.grid$soil[meuse.grid$soil==1]<- NA
meuse.grid$soil[meuse.grid$soil==2 | meuse.grid$soil==3]<- 5
spplot(meuse.grid[,,"soil"])
summary(meuse.grid$soil)
Regards,
Nikki
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo