Created
August 8, 2016 17:56
-
-
Save nrathnam/d590c02f4ccb6c1943e2ba086cc79157 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
### 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