Ruben Nuñez
04/07/2020
This peer assessed assignment has two parts. First, you will create a Shiny application and deploy it on Rstudio’s servers. Second, you will use Slidify or Rstudio Presenter to prepare a reproducible pitch presentation about your application.
Your Shiny Application:
The application must include the following:
It has been used a file provided by the ENI "Estatistics National Institute of Spain regarding Employment in the last 10 years.
And the objective of the app is to help on the data analysis of its content.
library(plotly)
#setwd("R//ProgrammingAssigment9.3")
employdata<- read.csv("employment.csv")
head(employdata)## Gender Age Period Total
## 1 Hombres 16 y mas anos 2019 56.3
## 2 Hombres 16 y mas anos 2018 55.7
## 3 Hombres 16 y mas anos 2017 54.6
## 4 Hombres 16 y mas anos 2016 53.3
## 5 Hombres 16 y mas anos 2015 52.1
## 6 Hombres 16 y mas anos 2014 50.3
shinyUI(fluidPage(
# Application title
titlePanel("Employment rates in spain"),
sidebarLayout(
sidebarPanel(
selectInput("age", label = h3("Age"),
choices = list("From 16 or more years" = 1, "From 16 to 24 years" = 2,
"From 16 to 54 years" = 3, "From 55 to 64 years" = 4,
"From 16 to 64 years" = 5),
selected = 1),
sliderInput("years",
h3("Number of Years:"),
min = 2009,
max = 2019,
value = c(2009, 2019)),
),
# Show a plot of the generated distribution
mainPanel(
h3("Help text"),
helpText("Please move the selectors to move the age group and the needed
years to see the trend."),
plotlyOutput("distPlot"),
tableOutput('table')
)
)
))
shinyServer(function(input, output) {
output$distPlot <- renderPlotly({
#Load data
employdata<- read.csv("employmentspain.csv")
# generate bins based on input$bins from ui.R
if (input$age == 1) {
employdata <- employdata %>% filter(Age == "16 y mas anos")
}else if (input$age == 2){
employdata <- employdata %>% filter(Age == "De 16 a 24 anos")
}else if (input$age == 3){
employdata <- employdata %>% filter(Age == "De 25 a 54 anos")
}else if (input$age == 4){
employdata <- employdata %>% filter(Age == "De 55 a 64 anos")
}else if (input$age == 5){
employdata <- employdata %>% filter(Age == "De 16 a 64 anos")
}
employdata <- employdata %>% filter(between(Period, input$years[1], input$years[2]))
fig <- plot_ly(employdata, x = ~Period, y = ~Total, color=~Gender, type = 'scatter', mode = 'lines+markers')
})
})