Dear R users,

I have two data frames that consist of statistical information for most
countries around the world. One dataframe consists of the latitude and
longitude ("coord.csv") of each country, while the other consists of 100's
of different attributes ("countryattri.csv") for each country (like, GDP,
Population, etc.). The data is organized with a header and then countries
down the first column. I'm trying to run a spatial autocorrelation for each
column or attribute in the "attri" dataframe. The process for running this
on a single column is as follows:

example of "coord.csv" dataframe:

country, lat, long
Albania, 41.00, 20.00
Algeria, 28.00, 3.00
Angola, -12.30, 18.30

example of "countryattri.csv" dataframe:

country, GDP, Population
Albania, 100000, 20000
Algeria, 1200000, 300000
Angola, 1300000, 300000

>     Locate<-read.csv("coord.csv", header = TRUE, sep = ",")
>     Locate.dists<-as.matrix(dist(cbind(Locate$long, Locate$lat)))
>     Locate.dists.inv<-1/((Locate.dists)^2)
>     diag(Locate.dists.inv)<-0
>     attri<-read.csv("countryattri.csv", header = TRUE, sep = ",")
>     Moran.I(attri$GDP, Locate.dists.inv, na.rm = TRUE)

This gives you Moran's I (correlation coefficient) for the GDP column in the
"attri" dataframe. I am trying to run the Moran.I function as a loop for all
columns in the "attri" dataframe so that I can obtain Moran coefficients for
every attribute.

I've tried a number of different approaches but cannot get a column loop to
run through this function. I would be very grateful if someone could help me
with this problem.

Thank you,

*Scott Seely*
p.s. the Moran.I function is a part of the "ape" package.

	[[alternative HTML version deleted]]

