I chose to use some census data for the town of Carmacks, Yukon, Canada. I plotted the same data twice using two approaches to plotly:
library(readr)
library(dplyr)
library(ggplot2)
library(plotly)
# LOad the data and then filter out a subset for class exercise
dat <- read_csv("C:/P_Teaching/P_SpainIntro/SpainIntro_Data/PopTidyData.csv")
sub1 <- dplyr::filter(dat, Sex!="Total" & Month=="December" & AgeClass=="All Ages")
g <- ggplot(data=sub1, aes(Year, CountIndividuals, color=Sex))+
geom_point(stat="identity") +
geom_line() +
ggtitle("Carmacks December Census")
ggplotly(g)
plot_ly(sub1, x = ~Year, y = ~CountIndividuals, color = ~Sex,
type = 'scatter', mode = 'lines',
text = ~paste("Population: ", CountIndividuals)) %>%
layout(title = 'Carmacks December Census')