I am trying to add some more variables to the "lab 5" portion of the dataset creation, but I am running into an error where it says it can't select columns that don't exist, but they do exist in the dataset. It is almost as if when the d1 & d2 & md merged, it masked variables from d2. Any advice?
URL1 <- "https://github.com/DS4PS/cpp-529-fall-2020/raw/main/LABS/data/rodeo/LTDB-2000.rds"
d1 <- readRDS( gzcon( url( URL1 ) ) )
URL2 <- "https://github.com/DS4PS/cpp-529-fall-2020/raw/main/LABS/data/rodeo/LTDB-2010.rds"
d2 <- readRDS( gzcon( url( URL2 ) ) )
URLmd <- "https://github.com/DS4PS/cpp-529-fall-2020/raw/main/LABS/data/rodeo/LTDB-META-DATA.rds"
md <- readRDS( gzcon( url( URLmd ) ) )
d1 <- select( d1, - year )
d2 <- select( d2, - year )
d <- merge( d1, d2, by="tractid" )
d <- merge( d, md, by="tractid" )
# STANDARDIZE GEO IDs
# note the current geoid format for the LTDB census data:
# FIPS-STATE-COUNTY-TRACT: fips-01-001-020100
x <- d$tractid
head( x )
# [1] "fips-01-001-020100" "fips-01-001-020200" "fips-01-001-020300"
# [4] "fips-01-001-020400" "fips-01-001-020500" "fips-01-001-020600"
# remove non-numeric strings
x <- gsub( "fips", "", x )
x <- gsub( "-", "", x )
head( x )
# [1] "01001020100" "01001020200" "01001020300" "01001020400" "01001020500"
# [6] "01001020600"
# drop leading zeros
x <- as.numeric( x )
# remember to add the variable back to the census dataset
d$tractid2 <- x
las.map <- merge( las_dorling, d, by.x="GEOID", by.y="tractid", all.x=T )
Above is the code I am trying to run, this is the error when I run the last portion (the creation of d3):
Error: Can't subset columns that don't exist.
x Column pnhblack12 doesn't exist.
I am trying to add some more variables to the "lab 5" portion of the dataset creation, but I am running into an error where it says it can't select columns that don't exist, but they do exist in the dataset. It is almost as if when the d1 & d2 & md merged, it masked variables from d2. Any advice?
Above is the code I am trying to run, this is the error when I run the last portion (the creation of d3): Error: Can't subset columns that don't exist. x Column
pnhblack12
doesn't exist.