Skip to content

Instantly share code, notes, and snippets.

@nrathnam
Created August 8, 2016 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrathnam/d590c02f4ccb6c1943e2ba086cc79157 to your computer and use it in GitHub Desktop.
Save nrathnam/d590c02f4ccb6c1943e2ba086cc79157 to your computer and use it in GitHub Desktop.
### Code for Insight: Responses tab
choiceResponseInsight <- reactive({
capitalize(input$responseInsightRB)
})
output$txtResponseInsight <- renderText({
if (choiceResponseInsight() == "% Disputed Responses") { "Percentage of Disputed Responses" }
if (choiceResponseInsight() == "% Delayed Responses") { "Percentage of Delayed Responses" }
if (choiceResponseInsight() == "% Cases closed with Monetary Relief") { "Percentage of Cases closed with Monetary Relief" }
print (choiceResponseInsight())
})
graphInputInsight <- reactive({
# Choosing information based on widget inputs
print (input$productInsightCG)
if (input$responseInsightRB == "% Disputed Responses") { graphdat <- reshaped_disputed_response }
if (input$responseInsightRB == "% Delayed Responses") { graphdat <- reshaped_late_response }
if (input$responseInsightRB == "% Cases closed with Monetary Relief") { graphdat <- reshaped_monetary_relief }
i = c()
if ("Bank account or service" %in% input$productInsightCG) {
i[length(i)+1] = 2
}
if ("Consumer Loan" %in% input$productInsightCG) {
i[length(i)+1] = 3
}
if ("Credit card" %in% input$productInsightCG) {
i[length(i)+1] = 4
}
if ("Credit reporting" %in% input$productInsightCG) {
i[length(i)+1] = 5
}
if ("Debt collection" %in% input$productInsightCG) {
i[length(i)+1] = 6
}
if ("Money transfers" %in% input$productInsightCG) {
i[length(i)+1] = 7
}
if ("Mortgage" %in% input$productInsightCG) {
i[length(i)+1] = 8
}
if ("Student loan" %in% input$productInsightCG) {
i[length(i)+1] = 9
}
firstcol = 1
print(i)
i = c(firstcol, i)
print(i)
graphdat = graphdat[, c(i)]
return (data.frame(graphdat))
})
# Graphing data of interest
output$plotInsight <- renderGvis({
gvisLineChart(
graphInputInsight(), options=list(
lineWidth=3, pointSize=5,
vAxis="{title:'Response Metric' , format:'#.##%' }",
hAxis="{title:'Year', format:'#####'}",
width=750, height=500))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment