[R] Comparing to create a new list

RobertDavis rdavis7408 at gmail.com
Tue Jun 19 17:55:55 CEST 2012


I have a shape file that I have read into R. It is a US Census shape file
that has a code for each school district in a state.

I now want to create a vector of the districts that are not customers and
plot them.

library(maptools)
library(maps)

elem_school_district <- readShapePoly("E:/My Documents/Web
Usage/RTest/School_District_Shape_Files/Elementary School
Districts/unzipped/tl_2010_47_elsd10.shp", IDvar="NAME10",
proj4string=CRS("+pro=11 + ellps=clrk66"))

secondary_school_district <- readShapePoly("E:/My Documents/Web
Usage/RTest/School_District_Shape_Files/Secondary School
Districts/unzipped/tl_2010_47_scsd10.shp", IDvar="NAME10",
proj4string=CRS("+proj=ll + ellps=clrk66"))

unified_school_district <- readShapePoly("E:/My Documents/Web
Usage/RTest/School_District_Shape_Files/Unified_School_Districts/Unzipped/tl_2010_47_unsd10.shp",
IDvar="NAME10", proj4string=CRS("+proj=ll + ellps=clrk66"))

plot(elem_school_district, col="green")
plot(secondary_school_district, col="blue", add=TRUE)
plot(unified_school_district, col="red", add=TRUE)

i=1
counter=1
schools_not_customers <- c("4700570", "470090", "4701590", "4700570")

for (counter in length(schools_not_customers)) {


for (i in length(unified_school_district)) {
	
	if (unified_school_district$GEOID10 == schools_not_customers[counter]){
	color_white_districts<-unified_school_district[i,]
	
		
	}
	     
		
		}
counter=counter+1
}
plot(color_white_districts, col="white", add=TRUE)

The above does not work can someone point me in the right direction? 

I would appreciate it. Thanks in advance.

--
View this message in context: http://r.789695.n4.nabble.com/Comparing-to-create-a-new-list-tp4633856.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list