This is a task for the data science coursera course about developing data products for week 4.
Shiny app: https://courseprojectweek3.shinyapps.io/week4courseproject/ Presentation: https://github.com/JannekeSchipper/Course-9—Developing-Data-products
11 januari 2020
This is a task for the data science coursera course about developing data products for week 4.
Shiny app: https://courseprojectweek3.shinyapps.io/week4courseproject/ Presentation: https://github.com/JannekeSchipper/Course-9—Developing-Data-products
Top 10 countries who use the most plastic in the world
## X Entity Code Plastic GDPPC Literacy InfantMortality Agriculture ## 1 1 Kuwait KWT 0.686 28985 0.963 7.1 0.004 ## 2 2 Guyana GUY 0.586 4127 0.885 31.5 0.182 ## 3 3 Barbados BRB 0.570 15360 0.997 8.8 0.017 ## 4 4 Saint Lucia LCA 0.522 7764 0.901 11.2 0.029 ## 5 5 Germany DEU 0.485 41219 0.990 3.4 0.007 ## 6 6 Netherlands NLD 0.424 44433 0.990 3.6 0.018 ## Population NetMigration ## 1 3892000 -2.0 ## 2 767085 -6.4 ## 3 284215 1.6 ## 4 184999 -2.7 ## 5 81410000 1.5 ## 6 16940000 1.9
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Top 10 Countries plastic useage"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("variable", "Variable:",
c("Plastic" = "Plastic",
"Gross Domestic Product Per Capita" = "GDPPC",
"Literacy" = "Literacy",
"Infant Mortality" = "InfantMortality",
"Population" = "Population"))
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
))
library(shiny)
library(plotly)
library(ggplot2)
library(dplyr)
dataset <- read.csv("./top10.csv")
top10 <- dataset%>%
top_n(10, Plastic)%>%
arrange(desc(Plastic))
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
formulaText <- reactive({
paste("courty vs ", input$variable)
})
output$caption <- renderText({
formulaText()
})
output$distPlot <- renderPlot({
ggplot(top10, aes_string(y=input$variable, x="Entity", fill = "Entity")) +
geom_bar(stat = "identity", width = 0.7) +
coord_flip() +
theme(legend.position="none") +
labs(title = "Top 10 Countries plastic usage", x = "Country")
})
})