library(readr)
san_francisco_suicide_2003_2017 <- read_csv("~/Library/CloudStorage/OneDrive-DrexelUniversity/CJS 310/Datasets/san_francisco_suicide_2003_2017.csv")
## Rows: 1292 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (8): Category, Descript, DayOfWeek, Date, PdDistrict, Resolution, Addre...
## dbl (5): IncidntNum, X, Y, PdId, year
## time (1): Time
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
suicide <- as.data.frame(san_francisco_suicide_2003_2017)
register_stadiamaps(key = "eeca01da-0a32-4982-a476-a63aa597111e")
sf_map <- ggmap(
get_stadiamap(
bbox = c(-122.530392, 37.698887, -122.351177, 37.812996),
maptype = "stamen_terrain"
)
)
## ℹ © Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors.
sf_map

sf_map +
geom_point(aes(x = X, y = Y),
data = suicide)
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

sf_map +
geom_point(aes(x = X, y = Y),
data = suicide,
color = "forestgreen")
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

sf_map +
geom_point(aes(x = X, y = Y),
data = suicide,
color = "forestgreen",
size = 0.5)
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

sf_map +
geom_point(aes(x = X, y = Y),
data = suicide,
color = "forestgreen",
size = 2,
alpha = 0.5)
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

plot(suicide$X, suicide$Y, col = "forestgreen")

sf_map +
stat_binhex(aes(x = X, y = Y),
bins = 60,
data = suicide) +
coord_cartesian() +
scale_fill_gradient(low = "#ffeda0",
high = "#f03b20")
## Coordinate system already present.
## ℹ Adding new coordinate system, which will replace the existing one.
## Warning: Removed 1 row containing non-finite outside the scale range
## (`stat_binhex()`).
