Data transformations The datasets: (1) NYC Subway Transit (2) BLM (Bureau of Land Management) uranium mines (CO,UT) (3) EPA Air Pollutants (Vertical tidy) Consider other set
library(tidyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(leaflet)
t <- read.csv("https://raw.githubusercontent.com/jconno/NYC-Subway-Transit/main/NYC_Transit_Subway_Entrance_And_Exit_Data.csv")
names(t)
## [1] "Division" "Line" "Station.Name"
## [4] "Station.Latitude" "Station.Longitude" "Route1"
## [7] "Route2" "Route3" "Route4"
## [10] "Route5" "Route6" "Route7"
## [13] "Route8" "Route9" "Route10"
## [16] "Route11" "Entrance.Type" "Entry"
## [19] "Exit.Only" "Vending" "Staffing"
## [22] "Staff.Hours" "ADA" "ADA.Notes"
## [25] "Free.Crossover" "North.South.Street" "East.West.Street"
## [28] "Corner" "Entrance.Latitude" "Entrance.Longitude"
## [31] "Station.Location" "Entrance.Location"
New dataset will omit: Division, Line, Exit Only, Staff Hours, ADA Notes, North South Street, East West Street, Corner, Entrance Latitude, Entrance Longitude, Station Location
Entrances and Exits INCLUDES: Station.Name, Routes 1-11, Entrance.Type, Vending, Staffing, Entrance.Location
stns <- t %>% select(Station.Name, Corner, Route1, Route2, Route3, Route4, Route5, Route6, Route7, Route8, Route9, Route10, Route11, Entrance.Type, Vending, Staffing, Station.Latitude, Station.Longitude)
#Combining all Route columns into 1:
stns <- unite(stns, Routes, Route1, Route2, Route3, Route4, Route5, Route6, Route7, Route8, Route9, Route10, Route11, sep = " " )
Station Helpfulness: Variables: Station.Name, ADA, Vending, Staffing, Staff.Hours, Free.Crossover, Corner
helpful <- t %>% select(Station.Name, Staffing, Vending, ADA, Entrance.Type, Exit.Only, Free.Crossover)
head(helpful)
## Station.Name Staffing Vending ADA Entrance.Type Exit.Only Free.Crossover
## 1 25th St FULL YES FALSE Stair FALSE
## 2 25th St NONE YES FALSE Stair FALSE
## 3 36th St FULL YES FALSE Stair TRUE
## 4 36th St FULL YES FALSE Stair TRUE
## 5 36th St FULL YES FALSE Stair TRUE
## 6 45th St FULL YES FALSE Stair TRUE
Station Staffing
table(helpful$Staffing)
##
## FULL NONE PART Spc Ev
## 1119 700 45 4
Free Crossover/Transfer
table(helpful$Free.Crossover)
##
## FALSE TRUE
## 420 1448
Exit Only
table(helpful$Exit.Only)
##
## Yes
## 1812 56
ADA Access
table(helpful$ADA)
##
## FALSE TRUE
## 1400 468
Vending Machines Available
table(helpful$Vending)
##
## NO YES
## 183 1685
Interactive Informative Map
pop_up <- paste(stns$Station.Name, "||", stns$Corner, "||", stns$Routes, ",", stns$Entrance.Type)
leaflet() %>%
addTiles() %>%
addCircleMarkers(lat = stns$Station.Latitude, lng = stns$Station.Longitude, popup = pop_up, color = "purple", stroke = FALSE, fillOpacity = 0.2)