Roger, I have to get experience yet... I thought that the right way to access the datas in Spatial*DataFrame should be through the use of slots. Thanks for the hint. Now things get easier! :-)
2008/3/12, Roger Bivand <[EMAIL PROTECTED]>: > On Wed, 12 Mar 2008, G. Allegri wrote: > > > I'm trying to change a column name of the data slot of a > SpatialPixelsDataFrame. > > I've added the column this way: > > > >> slot(EceZKRIG0_3,"data")[,index]<-Sim_mean_approx[[2]] > > > > The column added is V151 (as 151 is the actual index). > > I want to rename it, and I've tried: > > > >> names(slot(EceZKRIG0_3,"data")[index])<-"Mean_approx" > > > The point of the Spatial*DataFrame classes is to look like GIS to GIS > people and data.frames to data people. Isn't it easier just to say: > > EceZKRIG0_3$Mean_approx <- Sim_mean_approx[[2]] > > There is also a names()<- method, so if you wanted to change a name, you > could do it: > > names(EceZKRIG0_3)[151] <- "Mean_approx" > > library(sp) > data(meuse) > coordinates(meuse) <- c("x", "y") > class(meuse) > names(meuse) > meuse$s_lime <- sample(meuse$lime) > names(meuse) > names(meuse)[13] <- "not_slime" > names(meuse) > > OK? Isn't that easier? > > Roger > > > > > > No errors are raised, but the column remain V151. What's wrong? > > > > Giovanni > > > > > _______________________________________________ > > R-sig-Geo mailing list > > R-sig-Geo@stat.math.ethz.ch > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > > > -- > Roger Bivand > Economic Geography Section, Department of Economics, Norwegian School of > Economics and Business Administration, Helleveien 30, N-5045 Bergen, > Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 > e-mail: [EMAIL PROTECTED] > > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo