Created
December 6, 2015 22:37
-
-
Save davidcomfort/d83e2c179b87df93bfcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## The Wellbeing of the World | |
```{r, echo = FALSE} | |
#library(googleVis) | |
suppressPackageStartupMessages(library(googleVis)) | |
library(shiny) | |
myChoices <- c("Central Africa", "Central America and Caribbean", "Central Asia", | |
"East Africa","East Asia", "Eastern Europe", | |
"Middle East", "North Africa", "North America", | |
"Oceania", "South America", "South Asia", | |
"South-East Asia", "Southern Africa", "West Africa", "Western Europe") | |
# # setwd("/Users/2015/Dropbox/Data Science/NYC Data Science Academy/Shiny/Great-Escape") | |
gapdata <- readRDS("data/gapdata.per.capita.Rda") | |
gapdata$Sub.Region <- as.factor(gapdata$Sub.Region) | |
shinyApp( | |
ui = fluidPage( | |
sidebarLayout( | |
# Sidebar with a slider input | |
sidebarPanel( | |
checkboxGroupInput("Sub.Region", label = h4("Select Region"), myChoices, selected = myChoices), | |
submitButton(text="Ready") | |
), | |
# Show a plot | |
mainPanel( | |
htmlOutput("motionchart") | |
) | |
) | |
), | |
server = function(input, output, session) { | |
target_gapdata <- reactive({ | |
a <- subset(gapdata, gapdata$Sub.Region %in% input$Sub.Region) | |
a <- droplevels(a) | |
return(a) | |
}) | |
output$motionchart <- renderGvis({ | |
target_gapdata <- target_gapdata() | |
return (gvisMotionChart(target_gapdata, | |
idvar="Country", | |
colorvar="Sub.Region", | |
timevar="Years", | |
xvar="GDP.per.capita", | |
yvar="Life.Expectancy", | |
sizevar="Population", | |
date.format="%Y", | |
options=list(state=' | |
{"yAxisOption":"4","yLambda":1,"nonSelectedAlpha":0.4,"colorOption":"9","showTrails":true,"xZoomedDataMin":240.3630688,"xAxisOption":"2","yZoomedIn":false,"orderedByX":false,"sizeOption":"5","dimensions":{"iconDimensions":["dim0"]},"playDuration":15000,"time":"1800","uniColorForNonSelected":false,"iconKeySettings":[],"xZoomedDataMax":184563.1049,"duration":{"multiplier":1,"timeUnit":"Y"},"iconType":"BUBBLE","orderedByY":false,"yZoomedDataMax":83.58,"yZoomedDataMin":6,"xZoomedIn":false,"xLambda":0} | |
') | |
)) | |
}) | |
}, | |
options = list(height = 500) | |
) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment