The following report identifies specific tax parcels in Downtown Syracuse, New York (USA).
View the dataset documentation here: Syracuse, NY Tax Parcel Data.
The following packages are required for this report and loaded with library().
We read in spatial polygons ("sp") with function geojson_read() to map tax parcel shapes in Syracuse’s Downtown area.
url <- paste0("https://raw.githubusercontent.com/DS4PS/Data",
"-Science-Class/master/DATA/downtown-syr.geojson")
downtown <- geojson_read(url, what = "sp") # Load parcel data
plot(downtown,
border = "gray60",
col = "gray80") # Visualize parcels
The following examples demonstrate how to use conditions to identify specific parcels.
Parcels with more than one acre are determined with variable acres and condition > 1.
acres is tested as greater than one, or > 1acres greater than one become TRUE, otherwise FALSETRUE and FALSE values are stored in object these## Mode FALSE TRUE
## logical 330 59
All TRUE and FALSE values, for each parcel, are converted into colors.
group.colors <- ifelse(test = result, # 'test =' accepts TRUE or FALSE values
yes = "firebrick", # 'yes =' converts values that are TRUE
no = "gray80") # 'no =' converts values that are FALSEAll tax parcels in downtown are mapped with plot(). Each parcel has one of two colors per the above code.
plot(downtown, # Plots object 'downtown'
border = NA,
col = group.colors) # Red when TRUE; gray when FALSE
Use variable landuse to determine how a tax parcel is used. Determine all possible values with unique().
## [1] "Parking" "Commercial" "Parks"
## [4] "Community Services" "Vacant Land" "Utilities"
## [7] "Apartment" "Recreation" "Schools"
## [10] "Religious" "Industrial" "Single Family"
One of the values in landuse is “Single Family”. Therefore, the test is whether or not landuse is exactly equal to “Single Family”.
result <- downtown$landuse == "Single Family" # Test if 'landuse' is "Single Family"
group.colors <- ifelse(test = result, # Provide TRUE or FALSE test results
yes = "firebrick", # If TRUE, make "firebrick"
no = "gray80") # If FALSE, make "gray80"
plot(downtown,
border = NA,
col = group.colors) # Plot with respective colorsThe following questions ask you to map your results, write your answer, or both. The first question has been completed for you.
Question: Where are the majority of vacant lots located in the downtown? Map your results.
Note: This solution has been provided for you.
## [1] "Parking" "Commercial" "Parks"
## [4] "Community Services" "Vacant Land" "Utilities"
## [7] "Apartment" "Recreation" "Schools"
## [10] "Religious" "Industrial" "Single Family"
Now, we create our test statement, == "Vacant Land", and store the results in result.
result <- downtown$landuse == "Vacant Land"
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: How many parking lots are in downtown Syracuse? Map your results.
Answer: There are 78 parking lots in downtown Syracuse.
# Use function: 'sum()'
#unique(downtown$landuse)
# Use variable: 'landuse'
sum(downtown$landuse=="Parking")## [1] 78
# Assign test (logical) output to object 'result' by replacing 'FALSE'
result <- downtown$landuse=="Parking"
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: Where is new construction located in the city?. Map your results.
Note: You may use >= (greater than or equal) or > (greater than) 1980.
# Use variable: 'yearbuilt'
#is.data.frame(downtown)
#summary(downtown)
# Find the number of buildings constructed either after or during and after than 1980
#summary(downtown$yearbuilt)
#is.numeric(downtown$yearbuilt)
sum(downtown$yearbuilt >= 1980, na.rm = TRUE)## [1] 46
# Assign test (logical) output to object 'result' by replacing 'FALSE'
result <- downtown$yearbuilt >= 1980
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: What proportion of commercial properties are built since 1980?
Answer: 14.35% of commercial properties were built since 1980.
## [1] "Parking" "Commercial" "Parks"
## [4] "Community Services" "Vacant Land" "Utilities"
## [7] "Apartment" "Recreation" "Schools"
## [10] "Religious" "Industrial" "Single Family"
# Use variable: 'landuse'
total <- sum(downtown$landuse == "Commercial", na.rm=TRUE)
# Use variable: 'yearbuilt'
# Count only commercial properties with buildings constructed during or later than 1980
prop <- sum(downtown$landuse == "Commercial" & downtown$yearbuilt >= 1980, na.rm=TRUE)
prop/total*100## [1] 14.35407
#visual representation
result <- (downtown$landuse == "Commercial" & downtown$yearbuilt >= 1980)
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: How many parcels have assessed values over $10 million? Map your results.
Answer: 16 parcels have assessed values over $10 M.
# Use function: 'sum()'
# Use variable: 'assessedval'
#summary(downtown$assessedval)
sum(downtown$assessedval > 10000000)## [1] 16
# Assign test (logical) output to object 'result' by replacing 'FALSE'
result <- downtown$assessedval > 10000000
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: How many properties are delinquent on taxes? Map your results.
Answer: 57 properties are delinquent on taxes.
# Use function: 'sum()'
# Use variable: 'amtdelinqt'
#summary(downtown$amtdelinqt)
sum(downtown$amtdelinqt > 0)## [1] 57
# Assign test (logical) output to object 'result' by replacing 'FALSE'
result <- downtown$amtdelinqt > 0
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: What proportion of parcels have delinquent tax payments owed?
Answer: 14.65% of parcels have delinquent tax payments owed.
# Use function: 'mean()'
# Use variable: 'amtdelinqt'
group.delinqt <- downtown$amtdelinqt > 0
mean(group.delinqt)*100## [1] 14.65296
Question I: What proportion of commercial properties are delinquent on taxes?
Question II: What proportion of delinquent tax bills are owed by commercial parcels?
Answer I: 11.96% of commercial properties are delinquent on taxes.
Answer II: 43.86% of delinquent tax dollars are owed by commercial parcels.
# Use function: 'mean()'
# Use variable: 'amtdelinqt'
# Use variable: 'landuse'
group.comdeliqnt <- (downtown$landuse == "Commercial" & downtown$amtdelinqt > 0)
#mean(group.comdeliqnt)
#sum(group.comdeliqnt == TRUE)
# The first answer is tax-delinquent commercial properties over all commercial properties
total1<-sum(downtown$landuse=="Commercial")
prop1<-sum(downtown$landuse=="Commercial" & downtown$amtdelinqt >0)
prop1/total1## [1] 0.1196172
# The second answer is the tax dollars owed by commercial properties (a subset) over all tax dollars owed
total2<-sum(downtown$amtdelinqt > 0)
prop2<-prop1
prop2/total2## [1] 0.4385965
Question: How many of each land use type are delinquent on taxes? Print a table of your results.
# Use function: 'table()'
# Use variable: 'amtdelinqt'
# Use variable: 'landuse'
group.delinqt <- (downtown$amtdelinqt > 0)
table(downtown$landuse, group.delinqt)## group.delinqt
## FALSE TRUE
## Apartment 6 0
## Commercial 184 25
## Community Services 15 2
## Industrial 2 2
## Parking 62 16
## Parks 8 0
## Recreation 5 0
## Religious 6 0
## Schools 4 0
## Single Family 1 0
## Utilities 6 0
## Vacant Land 33 12
Instructions: Map all of the land valued at over $1 million per acre.
# Replace 'FALSE' with your conditional statement
#summary(downtown)
group.value <- downtown$assessedland/downtown$acres
#sum(group.value > 1000000)
result <- group.value > 1000000
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Instructions: Map all of the land valued at less than $500,000 per acre.
#summary(downtown$assessedland)
# Replace 'FALSE' with your conditional statement
#downtown$valperacre <- downtown$assessedland/downtown$acres
group.value <- downtown$assessedland/downtown$acres
result <- group.value < 500000
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Instructions: What is the total value of all of the commercial parcels in Downtown?
Answer: The total value of all commercial parcels is $317,067,000.
## [1] 317067000
## Apartment Commercial Community Services Industrial
## 38753600 317067000 158780600 15477700
## Parking Parks Recreation Religious
## 72228540 2315900 56290600 5655600
## Schools Single Family Utilities Vacant Land
## 14201500 110000 25803200 6330500
result <- downtown$landuse =="Commercial"
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Question: What is the total value of all of the non-commercial parcels in Downtown?
Answer: The total value of all non-commercial parcels is $395,947,740.
# Your code here
index <- downtown$landuse != "Commercial"
z <- downtown[index, ]
sum(z$assessedval)## [1] 395947740
result <- downtown$landuse != "Commercial"
group.colors <- ifelse(test = result,
yes = "firebrick",
no = "gray80")
plot(downtown,
border = NA,
col = group.colors)
Consider the following tips for completing this assignment.
Recall that logical values are TRUE and FALSE. To produce logical values, we test vaues against a condition, e.g. “greater than”.
x <- c(10, 20, 30, 40, 50) # Creating a vector of values
x > 25 # Testing each value as greater than 25## [1] FALSE FALSE TRUE TRUE TRUE
Recall that logical values are TRUE and FALSE, representing 1 and 0, respectively.
## [1] 1
## [1] 0
Because TRUE and FALSE are actually numeric, we can use sum() for total TRUE values, e.g.
y <- c(TRUE, TRUE,
FALSE, TRUE,
FALSE, TRUE) # Creating a vector of TRUE and FALSE
sum(y) # Finding total TRUE values## [1] 4
## [1] 0.6666667
A subset is a smaller collection of observations (rows) from a larger dataset. Create a subset by placing a logical vector in lieu of row positions.
index <- downtown$landuse == "Industrial" # Test if 'landuse' equals "Industrial"
z <- downtown[index, ] # Extract only "Industrial" parcels
Use the following instructions to submit your assignment, which may vary depending on your course’s platform.
When you have completed your assignment, click the “Knit” button to render your .RMD file into a .HTML report.
Perform the following depending on your course’s platform:
.RMD and .HTML files to the appropriate link.RMD and .HTML files in a .ZIP file and upload to the appropriate link.HTML files are preferred but not allowed by all platforms.
Remember to ensure the following before submitting your assignment.
head()See Google’s R Style Guide for examples of common conventions.
.RMD files are knit into .HTML and other formats procedural, or line-by-line.
install.packages() or setwd() are bound to cause errors in knittinglibrary() in a previous chunkIf All Else Fails: If you cannot determine and fix the errors in a code chunk that’s preventing you from knitting your document, add eval = FALSE inside the brackets of {r} at the beginning of a chunk to ensure that R does not attempt to evaluate it, that is: {r eval = FALSE}. This will prevent an erroneous chunk of code from halting the knitting process.