Dear All,

I want to generalize a soil map from 34 levels to 8. and i am getting this
error:
Error in x[i] == "Calcaric Cambisols" :
  comparison (1) is possible only for atomic and list types
In addition: Warning message:
In is.na(x[i]) : is.na() applied to non-(list or vector) of type 'S4'

any suggestions
this is my script

soil_raster_data <- overlay(dem, mw_soil.utm)   # result is a vector with
polygon ids
soil_raster_grp <- mw_soil.utm$FAO_CLASS[soil_raster_data] # now the factor
are stored
soil_raster <- SpatialGridDataFrame(dem@grid,
as.data.frame(soil_raster_grp))
x=soil_raster

levels(x) = c(levels(x), "cambisols", "gleysols", "regosols",
 "luvisols","vertisol","planosols","lixisols","alisols","ferralsols","NA")
#using the factor
for (i in 1:length(x)){
if (is.na(x[i]))
{x[i]="NA"}
else if (x[i] == "Calcaric Cambisols" || x[i] == "Chromic Cambisols" || x[i]
== "Dystric Cambisols"|| x[i] == "Eutric Cambisols"||x[i]=="Ferralic
Cambisols"||x[i] =="Gleyic Cambisols"||x[i] =="Vertic Cambisols")
{x[i] = "cambisols"}
else if  (x[i] == "Calcaric Gleysols"  || x[i] == "Eutric Gleysols")
 {x[i] = "gleysols"}
else if (x[i] == "Calcaric Regosols" || x[i] == "Cambic Arenosols" || x[i]
== "Eutric Fluvisols"|| x[i] == "Eutric Regosols"||x[i]=="Gleyic
Arenosols"||x[i] =="Haplic Acrisols"||x[i] =="Leptosols"|| x[i] == "Mollic
Fluvisols")
{x[i] = "regosols"}
else if (x[i] == "Calcic Luvisols" || x[i] == "Chromic Luvisols" || x[i] ==
"Ferric Luvisols"|| x[i] == "Gleyic Luvisols"||x[i]=="Haplic Luvisols")
{x[i] = "luvisols"}
else if  (x[i] == "Calcic Vertisol"  || x[i] == "Eutric Vertisol")
 {x[i] = "vertisol"}
else if  (x[i] == "Eutric Planosols")
 {x[i] = "planosols"}
else if  (x[i] == "salic"  || x[i] == "fluvic")
 {x[i] = "Ferric Lixisols"}
else if  (x[i] == "Haplic Alisols"  || x[i] == "Humic Alisols")
 {x[i] = "alisols"}
else if  (x[i] == "Haplic Ferralsols"  || x[i] == "Humic Ferralsols"||x[i]
== "Rhodic Ferralsols"  || x[i] == "Xanthic Ferralsols")
 {x[i] = "ferralsols"}}
Regards,

Nikkie

	[[alternative HTML version deleted]]

