Developing data products week3 Assigment

Ruben Nuñez

29/6/2020

Instructions

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!

Data

library(plotly)
#setwd("R//ProgrammingAssigment9.3")
employdata<- read.csv("employment.csv")
head(employdata)
##    Gender           Age Period Total
## 1 Hombres 16 y más años   2019  56.3
## 2 Hombres 16 y más años   2018  55.7
## 3 Hombres 16 y más años   2017  54.6
## 4 Hombres 16 y más años   2016  53.3
## 5 Hombres 16 y más años   2015  52.1
## 6 Hombres 16 y más años   2014  50.3

Code

fig <- plot_ly(employdata, x = ~Period, y = ~Total, color=~Gender, type = 'scatter', mode = 'lines+markers',
      transforms = list( list( type = 'filter', target = ~Age, operation = '=', value = unique(employdata$Age)[1]
      )
  )) %>%
      layout(
        title = "Employment in Spain",
        updatemenus = list(
          list(
          type = 'dropdown',
          active = 0,
            buttons = list(
               list(method = "restyle",
                   args = list("transforms[0].value", unique(employdata$Age)[1]),
                   label = unique(employdata$Age)[1]),
               list(method = "restyle",
                   args = list("transforms[0].value", unique(employdata$Age)[2]),
                   label = unique(employdata$Age)[2]),
               list(method = "restyle",
                   args = list("transforms[0].value", unique(employdata$Age)[3]),
                   label = unique(employdata$Age)[3]),
               list(method = "restyle",
                   args = list("transforms[0].value", unique(employdata$Age)[4]),
                   label = unique(employdata$Age)[4]),
               list(method = "restyle",
                   args = list("transforms[0].value", unique(employdata$Age)[5]),
                   label = unique(employdata$Age)[5]),
               list(method = "restyle",
                   args = list("transforms[0].value", unique(employdata$Age)[6]),
                   label = unique(employdata$Age)[6])
              ))))

Plot

fig