library(ggplot2)
## Warning: replacing previous import 'lifecycle::last_warnings' by
## 'rlang::last_warnings' when loading 'tibble'
## Warning: replacing previous import 'lifecycle::last_warnings' by
## 'rlang::last_warnings' when loading 'pillar'
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
View(economics)
eco <- plot_ly(economics,x= ~date,y=~unemploy,type = 'scatter',mode='markers')
eco
eco2 <- plot_ly(economics,x=~date)%>%
add_lines(y=~uempmed,name="median")%>%
add_lines(y=~unemploy,name="num in thousands")
eco2
eco3 <- eco2%>%
layout(title="Umployment",
xaxis=list(title=NA),
yaxis=list(title="Number of Employment"))
eco3
(a)data source: The economics data set is inside R and it describes the relationship between the rate of unemployment and the time series. The main variables I use here is “unemploy”(refers to the number of unemployed in thousands)
(b)Research question: I want to discover “Is there a increasing of the number of unemployed from 1967 to 2015 ?”
(c)Plot_ly is the function I mainly use here because the x-axis is timely series and y-axis is the response varibale.Also use the lay-out function to specify the names and titles.