Visnetwork shiny not working, - $ operator is invalid for atomic vectors
up vote
0
down vote
favorite
I am working on shiny app where I need to create a network chart using visNetwork.
While running the code I am getting following error-
Error in : $ operator is invalid for atomic vectors
Stack trace (innermost first):
77: origRenderFunc
76: output$kolNetwork
1: runApp
Below is my ui code-
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
#css to format the views
tags$style(
HTML("
#filterRow>div{
width: 140px;
display : inline-block;
margin-right: 15px;
}
.main-header{
display:none;
}
.content{
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #fff;
z-index: 1000;
}
.selectize-control.single .selectize-input, .selectize-control.single .selectize-input input{
height: 22px !important;
}
")
),
#code for main view
fluidRow(column(12,tags$div(style="height:10px;"))),
fluidRow(column(12,
tags$div(id = "filterRow",
selectInput("countryFilter", "Country", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$country))), selected = "Select", multiple = F, selectize = T),
selectInput("specialtyFilter", "Specialty", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select", multiple = F, selectize = T),
selectInput("sponsorFilter", "Sponsor", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select", multiple = F, selectize = T),
selectInput("kolFilter", "KOL", choices = "Select", selected = "Select", multiple = F, selectize = T),
actionButton("createNetwork", "Go", style = "margin-top: -2%; background-color :#3C8DBC; color: #fff; font-weight: 600; height: 40px; width: 110px;font-size: 20px;")
))
),
fluidRow(
column(9, tags$div(style = 'height: 700px;', visNetworkOutput("kolNetwork"))),
column(3, tags$div(style = 'height: 700px;', uiOutput("networkLegend")))
),
fluidRow(
column(
width=12,
box(
width = 12,title = "Influencer Details",solidHeader = T,status = "primary",collapsible = T, collapsed = F,
DTOutput("kolNetworkTable"),
tags$div(uiOutput("download"))
)
)
)
)
)
Below is the server.R file
server <- function(input, output, session){
#update rest columns on selection in country column
observeEvent(input$countryFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$countryFilter=="Select"){
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$specialtyFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$specialtyFilter=="Select"){
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$sponsorFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
}
if(input$sponsorFilter!="Select"){
node_file <- filter(node_file, sponsor %in% input$sponsorFilter & from_flag == "y")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
else if(input$sponsorFilter=="Select"){
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
}, ignoreInit = T)
#creating filtered dataset
filteredData <- eventReactive(input$createNetwork, {
temp <- copy(node_file[node_file$from_flag=="y",])
if(input$kolFilter!="Select"){
temp <- filter(temp, id %in% input$kolFilter)
}
if(input$sponsorFilter!="Select"){
temp <- filter(temp, sponsor %in% input$sponsorFilter)
}
if(input$specialtyFilter!="Select"){
temp <- filter(temp, specialty %in% input$specialtyFilter)
}
if(input$countryFilter!="Select"){
temp <- filter(temp, country %in% input$countryFilter)
}
})
# myNetworkChart <- function(edges, nodes){
#
# print("inside network chart function")
#
# output$kolNetwork <- renderVisNetwork({
#
# print("inside render visnetwork")
#
# edges <- data.frame(edges, width = edges$weight)
#
# nodes <- data.frame(nodes,
# size = nodes$pageranks*1000+3,
# title = nodes$id, borderWidth = 2,
# color.highlight.background = "yellow",
# shadow = list(enabled = TRUE, size = 10))
#
# #browser()
#
# visNetwork::visNetwork(nodes, edges, width = "100%", height = "100%")
# print("after render visnetwork")
# })
# }
observeEvent(input$createNetwork, {
#View(filteredData())
edges <- subset(edge_file, from %in% filteredData()$id)
nodes <- subset(node_file, id %in% edges$from | id %in% edges$to)
output$kolNetwork <- renderVisNetwork({
print("inside render visnetwork")
edges <- data.frame(edges, width = edges$weight)
nodes <- data.frame(nodes,
size = nodes$pageranks*1000+3,
title = nodes$id, borderWidth = 2,
color.highlight.background = "yellow",
shadow = list(enabled = TRUE, size = 10))
#browser()
visNetwork(nodes, edges, width = "100%", height = "100%")
print("after render visnetwork")
})
#myNetworkChart(edges, nodes)
}, ignoreInit = T)
#function to create network chart
}
Global.R only brings in the libraries and reads data file
r shiny shiny-server shinydashboard
add a comment |
up vote
0
down vote
favorite
I am working on shiny app where I need to create a network chart using visNetwork.
While running the code I am getting following error-
Error in : $ operator is invalid for atomic vectors
Stack trace (innermost first):
77: origRenderFunc
76: output$kolNetwork
1: runApp
Below is my ui code-
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
#css to format the views
tags$style(
HTML("
#filterRow>div{
width: 140px;
display : inline-block;
margin-right: 15px;
}
.main-header{
display:none;
}
.content{
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #fff;
z-index: 1000;
}
.selectize-control.single .selectize-input, .selectize-control.single .selectize-input input{
height: 22px !important;
}
")
),
#code for main view
fluidRow(column(12,tags$div(style="height:10px;"))),
fluidRow(column(12,
tags$div(id = "filterRow",
selectInput("countryFilter", "Country", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$country))), selected = "Select", multiple = F, selectize = T),
selectInput("specialtyFilter", "Specialty", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select", multiple = F, selectize = T),
selectInput("sponsorFilter", "Sponsor", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select", multiple = F, selectize = T),
selectInput("kolFilter", "KOL", choices = "Select", selected = "Select", multiple = F, selectize = T),
actionButton("createNetwork", "Go", style = "margin-top: -2%; background-color :#3C8DBC; color: #fff; font-weight: 600; height: 40px; width: 110px;font-size: 20px;")
))
),
fluidRow(
column(9, tags$div(style = 'height: 700px;', visNetworkOutput("kolNetwork"))),
column(3, tags$div(style = 'height: 700px;', uiOutput("networkLegend")))
),
fluidRow(
column(
width=12,
box(
width = 12,title = "Influencer Details",solidHeader = T,status = "primary",collapsible = T, collapsed = F,
DTOutput("kolNetworkTable"),
tags$div(uiOutput("download"))
)
)
)
)
)
Below is the server.R file
server <- function(input, output, session){
#update rest columns on selection in country column
observeEvent(input$countryFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$countryFilter=="Select"){
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$specialtyFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$specialtyFilter=="Select"){
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$sponsorFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
}
if(input$sponsorFilter!="Select"){
node_file <- filter(node_file, sponsor %in% input$sponsorFilter & from_flag == "y")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
else if(input$sponsorFilter=="Select"){
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
}, ignoreInit = T)
#creating filtered dataset
filteredData <- eventReactive(input$createNetwork, {
temp <- copy(node_file[node_file$from_flag=="y",])
if(input$kolFilter!="Select"){
temp <- filter(temp, id %in% input$kolFilter)
}
if(input$sponsorFilter!="Select"){
temp <- filter(temp, sponsor %in% input$sponsorFilter)
}
if(input$specialtyFilter!="Select"){
temp <- filter(temp, specialty %in% input$specialtyFilter)
}
if(input$countryFilter!="Select"){
temp <- filter(temp, country %in% input$countryFilter)
}
})
# myNetworkChart <- function(edges, nodes){
#
# print("inside network chart function")
#
# output$kolNetwork <- renderVisNetwork({
#
# print("inside render visnetwork")
#
# edges <- data.frame(edges, width = edges$weight)
#
# nodes <- data.frame(nodes,
# size = nodes$pageranks*1000+3,
# title = nodes$id, borderWidth = 2,
# color.highlight.background = "yellow",
# shadow = list(enabled = TRUE, size = 10))
#
# #browser()
#
# visNetwork::visNetwork(nodes, edges, width = "100%", height = "100%")
# print("after render visnetwork")
# })
# }
observeEvent(input$createNetwork, {
#View(filteredData())
edges <- subset(edge_file, from %in% filteredData()$id)
nodes <- subset(node_file, id %in% edges$from | id %in% edges$to)
output$kolNetwork <- renderVisNetwork({
print("inside render visnetwork")
edges <- data.frame(edges, width = edges$weight)
nodes <- data.frame(nodes,
size = nodes$pageranks*1000+3,
title = nodes$id, borderWidth = 2,
color.highlight.background = "yellow",
shadow = list(enabled = TRUE, size = 10))
#browser()
visNetwork(nodes, edges, width = "100%", height = "100%")
print("after render visnetwork")
})
#myNetworkChart(edges, nodes)
}, ignoreInit = T)
#function to create network chart
}
Global.R only brings in the libraries and reads data file
r shiny shiny-server shinydashboard
Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on shiny app where I need to create a network chart using visNetwork.
While running the code I am getting following error-
Error in : $ operator is invalid for atomic vectors
Stack trace (innermost first):
77: origRenderFunc
76: output$kolNetwork
1: runApp
Below is my ui code-
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
#css to format the views
tags$style(
HTML("
#filterRow>div{
width: 140px;
display : inline-block;
margin-right: 15px;
}
.main-header{
display:none;
}
.content{
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #fff;
z-index: 1000;
}
.selectize-control.single .selectize-input, .selectize-control.single .selectize-input input{
height: 22px !important;
}
")
),
#code for main view
fluidRow(column(12,tags$div(style="height:10px;"))),
fluidRow(column(12,
tags$div(id = "filterRow",
selectInput("countryFilter", "Country", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$country))), selected = "Select", multiple = F, selectize = T),
selectInput("specialtyFilter", "Specialty", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select", multiple = F, selectize = T),
selectInput("sponsorFilter", "Sponsor", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select", multiple = F, selectize = T),
selectInput("kolFilter", "KOL", choices = "Select", selected = "Select", multiple = F, selectize = T),
actionButton("createNetwork", "Go", style = "margin-top: -2%; background-color :#3C8DBC; color: #fff; font-weight: 600; height: 40px; width: 110px;font-size: 20px;")
))
),
fluidRow(
column(9, tags$div(style = 'height: 700px;', visNetworkOutput("kolNetwork"))),
column(3, tags$div(style = 'height: 700px;', uiOutput("networkLegend")))
),
fluidRow(
column(
width=12,
box(
width = 12,title = "Influencer Details",solidHeader = T,status = "primary",collapsible = T, collapsed = F,
DTOutput("kolNetworkTable"),
tags$div(uiOutput("download"))
)
)
)
)
)
Below is the server.R file
server <- function(input, output, session){
#update rest columns on selection in country column
observeEvent(input$countryFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$countryFilter=="Select"){
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$specialtyFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$specialtyFilter=="Select"){
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$sponsorFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
}
if(input$sponsorFilter!="Select"){
node_file <- filter(node_file, sponsor %in% input$sponsorFilter & from_flag == "y")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
else if(input$sponsorFilter=="Select"){
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
}, ignoreInit = T)
#creating filtered dataset
filteredData <- eventReactive(input$createNetwork, {
temp <- copy(node_file[node_file$from_flag=="y",])
if(input$kolFilter!="Select"){
temp <- filter(temp, id %in% input$kolFilter)
}
if(input$sponsorFilter!="Select"){
temp <- filter(temp, sponsor %in% input$sponsorFilter)
}
if(input$specialtyFilter!="Select"){
temp <- filter(temp, specialty %in% input$specialtyFilter)
}
if(input$countryFilter!="Select"){
temp <- filter(temp, country %in% input$countryFilter)
}
})
# myNetworkChart <- function(edges, nodes){
#
# print("inside network chart function")
#
# output$kolNetwork <- renderVisNetwork({
#
# print("inside render visnetwork")
#
# edges <- data.frame(edges, width = edges$weight)
#
# nodes <- data.frame(nodes,
# size = nodes$pageranks*1000+3,
# title = nodes$id, borderWidth = 2,
# color.highlight.background = "yellow",
# shadow = list(enabled = TRUE, size = 10))
#
# #browser()
#
# visNetwork::visNetwork(nodes, edges, width = "100%", height = "100%")
# print("after render visnetwork")
# })
# }
observeEvent(input$createNetwork, {
#View(filteredData())
edges <- subset(edge_file, from %in% filteredData()$id)
nodes <- subset(node_file, id %in% edges$from | id %in% edges$to)
output$kolNetwork <- renderVisNetwork({
print("inside render visnetwork")
edges <- data.frame(edges, width = edges$weight)
nodes <- data.frame(nodes,
size = nodes$pageranks*1000+3,
title = nodes$id, borderWidth = 2,
color.highlight.background = "yellow",
shadow = list(enabled = TRUE, size = 10))
#browser()
visNetwork(nodes, edges, width = "100%", height = "100%")
print("after render visnetwork")
})
#myNetworkChart(edges, nodes)
}, ignoreInit = T)
#function to create network chart
}
Global.R only brings in the libraries and reads data file
r shiny shiny-server shinydashboard
I am working on shiny app where I need to create a network chart using visNetwork.
While running the code I am getting following error-
Error in : $ operator is invalid for atomic vectors
Stack trace (innermost first):
77: origRenderFunc
76: output$kolNetwork
1: runApp
Below is my ui code-
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
#css to format the views
tags$style(
HTML("
#filterRow>div{
width: 140px;
display : inline-block;
margin-right: 15px;
}
.main-header{
display:none;
}
.content{
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #fff;
z-index: 1000;
}
.selectize-control.single .selectize-input, .selectize-control.single .selectize-input input{
height: 22px !important;
}
")
),
#code for main view
fluidRow(column(12,tags$div(style="height:10px;"))),
fluidRow(column(12,
tags$div(id = "filterRow",
selectInput("countryFilter", "Country", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$country))), selected = "Select", multiple = F, selectize = T),
selectInput("specialtyFilter", "Specialty", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select", multiple = F, selectize = T),
selectInput("sponsorFilter", "Sponsor", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select", multiple = F, selectize = T),
selectInput("kolFilter", "KOL", choices = "Select", selected = "Select", multiple = F, selectize = T),
actionButton("createNetwork", "Go", style = "margin-top: -2%; background-color :#3C8DBC; color: #fff; font-weight: 600; height: 40px; width: 110px;font-size: 20px;")
))
),
fluidRow(
column(9, tags$div(style = 'height: 700px;', visNetworkOutput("kolNetwork"))),
column(3, tags$div(style = 'height: 700px;', uiOutput("networkLegend")))
),
fluidRow(
column(
width=12,
box(
width = 12,title = "Influencer Details",solidHeader = T,status = "primary",collapsible = T, collapsed = F,
DTOutput("kolNetworkTable"),
tags$div(uiOutput("download"))
)
)
)
)
)
Below is the server.R file
server <- function(input, output, session){
#update rest columns on selection in country column
observeEvent(input$countryFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$countryFilter=="Select"){
updateSelectInput(session, "specialtyFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$specialty))), selected = "Select")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$specialtyFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
else if(input$specialtyFilter=="Select"){
updateSelectInput(session, "sponsorFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$sponsor))), selected = "Select")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$id))), selected = "Select")
}
}, ignoreInit = T)
observeEvent(input$sponsorFilter, {
if(input$countryFilter!="Select"){
node_file <- filter(node_file, country %in% input$countryFilter & from_flag == "y")
}
if(input$specialtyFilter!="Select"){
node_file <- filter(node_file, specialty %in% input$specialtyFilter & from_flag == "y")
}
if(input$sponsorFilter!="Select"){
node_file <- filter(node_file, sponsor %in% input$sponsorFilter & from_flag == "y")
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
else if(input$sponsorFilter=="Select"){
updateSelectInput(session, "kolFilter", choices = c("Select", sort(unique(node_file[node_file$from_flag == "y",]$kol))), selected = "Select")
}
}, ignoreInit = T)
#creating filtered dataset
filteredData <- eventReactive(input$createNetwork, {
temp <- copy(node_file[node_file$from_flag=="y",])
if(input$kolFilter!="Select"){
temp <- filter(temp, id %in% input$kolFilter)
}
if(input$sponsorFilter!="Select"){
temp <- filter(temp, sponsor %in% input$sponsorFilter)
}
if(input$specialtyFilter!="Select"){
temp <- filter(temp, specialty %in% input$specialtyFilter)
}
if(input$countryFilter!="Select"){
temp <- filter(temp, country %in% input$countryFilter)
}
})
# myNetworkChart <- function(edges, nodes){
#
# print("inside network chart function")
#
# output$kolNetwork <- renderVisNetwork({
#
# print("inside render visnetwork")
#
# edges <- data.frame(edges, width = edges$weight)
#
# nodes <- data.frame(nodes,
# size = nodes$pageranks*1000+3,
# title = nodes$id, borderWidth = 2,
# color.highlight.background = "yellow",
# shadow = list(enabled = TRUE, size = 10))
#
# #browser()
#
# visNetwork::visNetwork(nodes, edges, width = "100%", height = "100%")
# print("after render visnetwork")
# })
# }
observeEvent(input$createNetwork, {
#View(filteredData())
edges <- subset(edge_file, from %in% filteredData()$id)
nodes <- subset(node_file, id %in% edges$from | id %in% edges$to)
output$kolNetwork <- renderVisNetwork({
print("inside render visnetwork")
edges <- data.frame(edges, width = edges$weight)
nodes <- data.frame(nodes,
size = nodes$pageranks*1000+3,
title = nodes$id, borderWidth = 2,
color.highlight.background = "yellow",
shadow = list(enabled = TRUE, size = 10))
#browser()
visNetwork(nodes, edges, width = "100%", height = "100%")
print("after render visnetwork")
})
#myNetworkChart(edges, nodes)
}, ignoreInit = T)
#function to create network chart
}
Global.R only brings in the libraries and reads data file
r shiny shiny-server shinydashboard
r shiny shiny-server shinydashboard
asked Nov 22 at 15:16
Vaibhav
458
458
Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42
add a comment |
Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42
Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42
Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53433915%2fvisnetwork-shiny-not-working-operator-is-invalid-for-atomic-vectors%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42