Skip to content

change a column name of the data slot

3 messages · G. Allegri, Roger Bivand

#
I'm trying to change a column name of the data slot of a SpatialPixelsDataFrame.
I've added the column this way:
The column added is V151 (as 151 is the actual index).
I want to rename it, and I've tried:
No errors are raised, but the column remain V151. What's wrong?

Giovanni
#
On Wed, 12 Mar 2008, G. Allegri wrote:

            
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

  
    
#
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 <Roger.Bivand at nhh.no>: