I have added my files with interaction graphics here !!
library(tidyverse)
library(viridis)
library(p8105.datasets)
library(plotly)
data("ny_noaa")
ny_noaa_new =
ny_noaa %>%
janitor::clean_names() %>%
separate(col = date, into = c("year", "month", "day")) %>%
select(id,year,month,day,tmax,tmin) %>%
filter(
id == "USW00094728",
year == c(1991:2000)
) %>%
mutate(
tmax = as.numeric(tmax),
tmin = as.numeric(tmin),
tmin = tmin / 10,
tmax = tmax / 10,
month = as.numeric(month),
month = month.name[month],
month = fct_relevel(
month, "January","February","March","April","May","June","July","August","September","October","November","December"),
name = recode(
id, USW00094728 = "CentralPark_NY"
)
)
## Warning in year == c(1991:2000): longer object length is not a multiple of
## shorter object length
ny_noaa_new %>%
mutate(text_label = str_c("Year: ", year," Month: ", month, " Date: ", day)) %>%
plot_ly(
x = ~tmax, y = ~tmin, type = "scatter", mode = "markers",
color = ~month, text = ~text_label) %>%
layout(title = "Minimum and Maximum temperature in Central Park, NY from 1991-2000")
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
weather_df =
ny_noaa %>%
janitor::clean_names() %>%
separate(col = date, into = c("year", "month", "day")) %>%
select(id,year,month,day,snow,prcp) %>%
filter(
id == "USW00094728",
year == 2000
) %>%
mutate(
name = recode(id, USW00094728 = "CentralPark_NY")
) %>%
group_by(month) %>%
summarise(
avg_prcp = sum(prcp)/30
) %>%
mutate(
month = as.numeric(month),
month = month.name[month],
month = fct_relevel(
month, "January","February","March","April","May","June","July","August","September","October","November","December")
)
weather_df %>%
plot_ly(x = ~month, y = ~avg_prcp, color = ~month, type = "bar") %>%
layout(title = "Average precipitation in Central Park, NY in 2000"
)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
ny_noaa_new =
ny_noaa %>%
janitor::clean_names() %>%
separate(col = date, into = c("year", "month", "day")) %>%
select(id,year,month,day,tmax,tmin) %>%
filter(
id == "USW00094728",
year == 2000
) %>%
mutate(
name = recode(id, USW00094728 = "CentralPark_NY")
) %>%
mutate(
tmax = as.numeric(tmax),
tmin = as.numeric(tmin),
tmin = tmin / 10,
tmax = tmax / 10,
month = as.numeric(month),
month = month.name[month],
month = fct_relevel(
month, "January","February","March","April","May","June","July","August","September","October","November","December")
)
ny_noaa_new %>%
plot_ly(y = ~tmax, color = ~month, type = "box",
colors = "Set2") %>%
layout(title = "Mximum temperature across all the months in Central Park, NY in 2000"
)