plot(cars)
library(tidyverse)
library(RSocrata)
library(knitr)
library(DT)
library(ggcharts) # for easy visualizations based on ggplot2
library(ggblanket) # for easy visualizations based on ggplot2
# import the data directly into RStudio using url path
data <- read.socrata("https://data.cityofnewyork.us/resource/enfh-gkve.csv")
plot(cars)
library(tidyverse)
library(RSocrata)
library(knitr)
library(DT)
library(ggcharts) # for easy visualizations based on ggplot2
library(ggblanket) # for easy visualizations based on ggplot2
# import the data directly into RStudio using url path
data <- read.socrata("https://data.cityofnewyork.us/resource/enfh-gkve.csv")
mydata |>
select(1:5) |>
slice(1:10) |> kable()
| name311 | typecategory | subcategory | acres | borough |
|---|---|---|---|---|
| Fisher Pool | Buildings/Institutions | Building | 0.817 | Q |
| Queens Valley Playground | Jointly Operated Playground | JOP | 0.876 | Q |
| Rockaway Beach and Boardwalk | Waterfront Facility | Mall | 3.809 | Q |
| Calvary Monument | Cemetery | Sitting Area/Triangle/Mall | 0.048 | Q |
| Her-King Alagantic Garden | Garden | 0.045 | B | |
| Magic Garden | Garden | 0.104 | M | |
| John Hancock Playground | Jointly Operated Playground | JOP | 1.547 | B |
| Moore Homestead Playground | Neighborhood Park | Neighborhood Plgd | 1.978 | Q |
| Hugh J. Grant Circle | Triangle/Plaza | Sitting Area/Triangle/Mall | 1.110 | X |
| Beaver Noll Park | Playground | Neighborhood Plgd | 0.436 | B |
mydata |>
filter(borough == "M") |>
select(c(name311,typecategory,acres)) |>
arrange(desc(acres)) |>
slice(1:20) |>
kable()
| name311 | typecategory | acres |
|---|---|---|
| Central Park | Flagship Park | 840.010 |
| Randall’s Island Park | Flagship Park | 254.300 |
| Riverside Park | Community Park | 253.168 |
| Inwood Hill Park | Community Park | 196.398 |
| Fort Washington Park | Community Park | 184.143 |
| Wards Island Park | Recreation Field/Courts | 170.700 |
| Highbridge Park | Community Park | 130.100 |
| Riverside Park South | Community Park | 71.933 |
| Fort Tryon Park | Community Park | 67.213 |
| Harlem River Park | Parkway | 46.657 |
| John V. Lindsay East River Park | Community Park | 45.880 |
| Morningside Park | Community Park | 29.888 |
| Battery Park City | Community Park | 26.042 |
| Recreational Area | Community Park | 23.093 |
| St. Nicholas Park | Neighborhood Park | 22.740 |
| The Battery | Neighborhood Park | 21.880 |
| Marcus Garvey Park | Community Park | 20.165 |
| Isham Park | Community Park | 20.132 |
| Theodore Roosevelt Park | Buildings/Institutions | 17.581 |
| Thomas Jefferson Park | Community Park | 15.524 |
mydata |>
filter(councildistrict == 6 | councildistrict == 6) |>
select(c(councildistrict,name311,acres)) |>
arrange(desc(acres)) |>
datatable() # for html only
#Filter by borough Manhattan
mydata |>
filter(borough == "M" | borough == "M") |>
select(c(borough,name311,acres)) |>
arrange(desc(acres)) |>
datatable() # for html only
#Filter by borough Bronx
mydata |>
filter(borough == "X" | borough == "X") |>
select(c(borough,name311,acres)) |>
arrange(desc(acres)) |>
datatable() # for html only
###How to excluse Vancortland and Pelhem Bay park?
#kable() # for pdf and html
borough_stats<-mydata |>
group_by(borough) |>
summarize(med_acres = median(acres, na.rm=TRUE),
avg_acres= mean(acres, na.rm=TRUE))
borough_stats |>
arrange(desc(med_acres)) |>
#kable()
datatable()
bar_chart(borough_stats, x=borough, y=med_acres)
borough_stats |>
arrange(desc(med_acres)) |>
#kable()
datatable()
bar_chart(borough_stats, x=borough, y=med_acres)
mydata |>
group_by(borough) |>
summarize(name311 = n()) |>
mutate(borough=reorder(borough,name311)) |>
ggplot(aes(x=borough,y=name311,fill=borough)) +
geom_col(show.legend = FALSE) +
coord_flip()
##How to make bar chart base on the size of the park and the brorough? ##How to calculate percentage of park per person?
overall_acres<- mydata |>
select(borough,name311,acres) |>
mutate(zscore = scale(acres)) |>
filter(!is.na(zscore))
Warning: Using one column matrices in `filter()` was deprecated in dplyr 1.1.0.
Please use one dimensional logical vectors instead.
####What is that Zscore?
mathprof_zscore |>
filter(borough %in% c("QUEENS","MANHATTAN","BROOKLYN","BRONX")) |>
gg_histogram(x=zscore,facet=borough, bins=12)