This dataset was produced from US economic time series data available from http://research.stlouisfed.org/fred2. Variables are normalised to the maximum value and renamed to give clearer labels. The unemployment rate (relative to the total population) is calculated.
suppressPackageStartupMessages(library(plotly))
suppressPackageStartupMessages(library(tidyr))
suppressPackageStartupMessages(library(dplyr))
ec<-mutate(economics,unemploy=unemploy/pop)
ec<-mutate(economics,pce=pce/max(pce))
ec<-mutate(ec,pop=pop/max(pop))
ec<-mutate(ec,psavert=psavert/max(psavert))
ec<-mutate(ec,uempmed=uempmed/max(uempmed))
ec<-mutate(ec,unemploy=unemploy/max(unemploy))
ec<-rename(ec,Savings_rate=psavert) %>%
rename (Population=pop)%>%
rename (Expediture=pce)%>%
rename (Unemployement_rate=unemploy)%>%
rename (Unemployement_duration=uempmed)
ecl<-gather(ec,variable,value,-date)
p <- plot_ly(ecl, x = ~date, y = ~value, color=~variable, type="scatter")
p
## No scatter mode specifed:
## Setting the mode to markers
## Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode