# (a) document name created, (b) CSV file downloaded, (c) variables reviewed (d) file downloaded
#set the working directory for this assignment
setwd("~/NYU/classes/2. R/Assignments/Lesson 3")
# (e) importing the federal stimulus data and changing the name to "fed_stimulus"
library(readr)
fed_stimulus <- read_csv("Federal_Stimulus_Data.csv")
## Rows: 13553 Columns: 37
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (28): Project Name, Project Description, Funding Category, Funding Sourc...
## dbl (9): Stimulus Tracker ID, Stimulus Funding, Displaced City Funding, All...
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
# (f) compute the sum and mean for the payment value column
sum(fed_stimulus$`Payment Value`, na.rm=TRUE)
## [1] 3180464994
mean(fed_stimulus$`Payment Value`, na.rm=TRUE)
## [1] 242044.5
# (g)To create a subset of your data that returns those projects with project status is equal to the completed 50% or more not including fully completed projects
fed_stim_ss <- subset.data.frame(fed_stimulus, fed_stimulus$`Project Status` =='Completed 50% or more')
dim(fed_stim_ss)
## [1] 4908 37
fed_stim_ss
## # A tibble: 4,908 x 37
## `Project Name` `Project Description` `Stimulus Track~ `Funding Categor~
## <chr> <chr> <dbl> <chr>
## 1 830 Amsterdam House~ Rooftop water tank 109062 Infrastructure
## 2 CUNY pilot program ~ Partnership with CUN~ 301006 Economic and Wor~
## 3 CUNY pilot program ~ Partnership with CUN~ 301006 Economic and Wor~
## 4 Whitman-Ingersoll H~ Apartment Upgrades 109012 Infrastructure
## 5 Highbridge Gardens ~ Brick & Roof. 109036 Infrastructure
## 6 CUNY pilot program ~ Partnership with CUN~ 301006 Economic and Wor~
## 7 Livonia Terrace Finance the construc~ 704003 Neighborhood Sta~
## 8 Interior Compactors~ Interior Compactors 109071 Infrastructure
## 9 FDNY Emergency Medi~ An intensive 12 week~ 301009 Economic and Wor~
## 10 Adoption Assistance~ Provide additional f~ 406001 Health and Socia~
## # ... with 4,898 more rows, and 33 more variables: Funding Source <chr>,
## # Stimulus Funding <dbl>, Displaced City Funding <dbl>,
## # All Other Funding <dbl>, Award Lead City Agency <chr>,
## # Project Lead City Agency <chr>, Project Status <chr>,
## # % of Funds Spent <dbl>, Date Funds Awarded by Fed/State <chr>,
## # Date Funds Announced by NYC <chr>, Estimated Start Date <chr>,
## # Actual Start Date <chr>, Actual Completion Date <chr>, ...