Skip to content

Instantly share code, notes, and snippets.

@kr-shiveshwar
Last active January 8, 2019 21:16
Show Gist options
  • Save kr-shiveshwar/949d1e03ec77856a861788844f2f7463 to your computer and use it in GitHub Desktop.
Save kr-shiveshwar/949d1e03ec77856a861788844f2f7463 to your computer and use it in GitHub Desktop.
Test
library(ggmap)
library(readr)
library(ggplot2)
library(ggraph)
load("eway_wo_zero_nodes")
load("transx_wo_zero")
load("pincodes_repository")
pincodes_repository <- pincodes_repository1
rm(pincodes_repository1)
pincodes_repository$pincode <- as.character(pincodes_repository$pincode)
source("Network Functions.R")
register_google(key = "AIzaSyC5yR6chTOOLeM60V3bs_b3r9JyRvmm5TU", account_type = "standard")
options(max.print = 50, scipen = 100)
shinyServer(function(input, output, session) {
selectedData <- reactive({
gstin_search_l1(input$g, trans_df = transx_wo_zero, nodes_df = eway_wo_zero_nodes, level = 2, n_at_l1 = input$n_at_l1, sortby = input$radio, n_at_l2 = 5)
})
output$TSPlot <- renderPlot({
gst_data <- selectedData()
map_graph(trans_df = gst_data$gstno_to_l1_transx, nodes_df = gst_data$gst_to_l1_nodes)
})
output$TSPlot1 <- renderPlot({
gst_data <- selectedData()
map_graph(trans_df = gst_data$l1_to_l2_transx_list[[1]], nodes_df = gst_data$l1_to_l2_nodes_list[[1]])
})
output$TSPlot2 <- renderPlot({
gst_data <- selectedData()
map_graph(trans_df = gst_data$l1_to_l2_transx_list[[2]], nodes_df = gst_data$l1_to_l2_nodes_list[[2]])
})
output$TSPlot3 <- renderPlot({
gst_data <- selectedData()
map_graph(trans_df = gst_data$l1_to_l2_transx_list[[3]], nodes_df = gst_data$l1_to_l2_nodes_list[[3]])
})
output$TSPlot4 <- renderPlot({
gst_data <- selectedData()
map_graph(trans_df = gst_data$l1_to_l2_transx_list[[4]], nodes_df = gst_data$l1_to_l2_nodes_list[[4]])
})
# output$
})
# ui.R
library(shiny)
library(shinydashboard)
# Create dashboard header
header <- dashboardHeader(title = "Network Analysis Dashboard")
# Create dashboard sidebar
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem(
text = "Filters",
tabName = "ID",
menuSubItem(
icon = NULL,
tabName = "ID",
selectInput("g","Select the GSTIN",
choices = c("29AAACW1336L1Z4",
"29AACCV0019M1Z7",
"29ACLFS6706J1ZJ",
"29AABCW5745N1ZM",
"29AAACB5724H1ZQ",
"29AAXFR3363A1ZW"),
selected = NULL)
),
menuSubItem(
icon = NULL,
tabName = "Sort by",
radioButtons("radio", label = "Sort by",
choices = list("Degree" = "degree", "Tax Value" = "Total_Tax_Val_Out"),
selected = NULL)
),
menuSubItem(
icon = NULL,
tabName = "Number at L1",
sliderInput("n_at_l1", label = "Number of L1",
min = 3, max = 8,
value = 5)
)
)
)
)
body <- dashboardBody(
tabBox(
title = "Level 1: Network",
# The id lets us use input$tabset1 on the server to find the current tab
id = "tabset1", height = "450px",
tabPanel("L1 : Top 5",plotOutput("TSPlot"))
),
tabBox(
title = "Level 2: Network",
# The id lets us use input$tabset1 on the server to find the current tab
height = "250px",
tabPanel("L2: N1",plotOutput("TSPlot1")),
tabPanel("L2: N2",plotOutput("TSPlot2")),
tabPanel("L2: N3",plotOutput("TSPlot3")),
tabPanel("L2: N4",plotOutput("TSPlot4"))
)
)
shinyUI(dashboardPage(skin = "purple",
header,
sidebar,
body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment