Examples w/ comments below.
Thank you-
Ben
# This is a test of my ability to call columns of a spatial data frame.
library(maptools)
data(wrld_simpl)
df.obs <- nrow(wrld_simpl)*10 #enough data for ten rows
df <- runif(df.obs,1,10) #create some data
df <- data.frame(matrix(df, nrow(wrld_simpl),10)) #slice it up
row.names(df) <- row.names(wrld_simpl)
newworld <- spCbind(wrld_simpl, df)
names(newworld)
# It is easy to call a column of the data by name.
class(newworld)
class(newworld$X1)
mean(newworld$X1)
# What about subscripts?
# The spatial polygons data frame doesn't have the right number of
dimentions. :(
class(newworld[,1])
# Get commands?
varname <- "newworld$X1" #This is a variable name
class(get(varname)) #But the get command can't find it....
# How can I write an apply()-family command over the variables in the
newworld spatial polygons data frame?