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










share|improve this question






















  • Some dummy data would be quite helpful.
    – ismirsehregal
    Nov 22 at 21:42















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










share|improve this question






















  • Some dummy data would be quite helpful.
    – ismirsehregal
    Nov 22 at 21:42













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










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 15:16









Vaibhav

458




458












  • 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




Some dummy data would be quite helpful.
– ismirsehregal
Nov 22 at 21:42

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo