Part 1: Plotly
## Change this to read in whatever data you're using
covid = read_csv("covid_data.csv")
## Parsed with column specification:
## cols(
## signal = col_character(),
## geo_value = col_character(),
## time_value = col_date(format = ""),
## value = col_double(),
## stderr = col_double(),
## sample_size = col_double()
## )
covid %>%
group_by(geo_value, signal) %>%
summarize(
avg = mean(value, na.rm = T)
) %>%
pivot_wider(id_cols = geo_value, names_from = signal, values_from = avg) %>%
ungroup() -> state_avg
## `summarise()` has grouped output by 'geo_value'. You can override using the `.groups` argument.
## Change this to make your plot
p1 = state_avg %>%
mutate(state = str_to_upper(geo_value)) %>%
ggplot(aes(x = smoothed_wearing_mask, y = smoothed_cli)) +
geom_point() +
theme_minimal()
ggplotly(p1)
p2 = state_avg %>%
mutate(state = str_to_upper(geo_value)) %>%
ggplot(aes(x = smoothed_wearing_mask, y = smoothed_cli)) +
geom_point(aes(text = toupper(geo_value))) +
theme_minimal()
## Warning: Ignoring unknown aesthetics: text
ggplotly(p2, tooltip = "text")
Part 2: Plotly on your own
brexit = read_csv("swarthmore.csv")
## Parsed with column specification:
## cols(
## `10.2564` = col_double(),
## `21.0817` = col_double()
## )
set.seed(011221)
samples = data.frame(matrix(rnorm(1000), ncol = 10))
colnames(samples) = paste0("sample", 1:10)
samples = tibble(samples)
p <- samples %>%
pivot_longer(1:10) %>%
ggplot(., aes(y = value, x = name, fill = name)) +
geom_boxplot(alpha = .7) +
scale_fill_viridis_d(end = .75, option = "C") +
scale_color_viridis_d(end = .75, option = "C") +
theme(legend.position = "none",
axis.text.x = element_text(size = 7))
fig <- ggplotly(p)
fig