I am getting above error whenever I am passing more than two conditions in if statement. I also tried 'all' instead of if statement but it also did not work.
Error is :
Warning in distType == "All" && distType == "normal" : 'length(x) = 2 > 1' in coercion to 'logical(1)'
Here is my code:
library(shiny)
library(networkD3)
Add custom CSS to style the navigation bar color and alignment
ui = fluidPage(
sidebarLayout(
sidebarPanel(width = 3,
selectInput("Distribution","please select"
,choices = c("All","normal"), multiple = TRUE, selected = "All"),
),
mainPanel(
forceNetworkOutput(outputId = "net")
)
))
server = function(input,output) {
Myclickaction = 'window.open(d.hyperlink, "_blank")' output$net = renderForceNetwork({
distType <- input$Distribution
if(distType == "All" && distType == "normal"){
fn <- forceNetwork(Links = MisLinks, Nodes = MisNodes,
Source = "source", Target = "target", charge = -150,
opacityNoHover = 1, Nodesize = "size",
Value = "value", NodeID = "name",
Group = "group", linkWidth = 2, clickAction = Myclickaction,
opacity = 0.9,fontSize = 20, width = 1000,height = 700,linkDistance = JS("function(d){return d.value * 40}"),colourScale =JS("d3.scaleOrdinal(d3.schemeCategory20);"),
zoom=TRUE)
fn$x$nodes$hyperlink <- MisNodes[["hyperlink"]]
fn
}else{
MyClickScript <-'window.open("http://localhost:9191/"+ d.name, "_blank");'
forceNetwork(Links = mislink, Nodes = misnod, Source = "source",
Target = "target", Value = "value", NodeID = "name",Nodesize = "size",
Group = "group", opacity = 1, zoom = T,opacityNoHover = TRUE,
fontSize = 20, width = 1000,height = 700,
bounded = TRUE, clickAction = MyClickScript,linkDistance =100)
}
})
} shinyApp(ui = ui, server = server)