#' Function to remove nodes from network, with shiny only.
#'
#' Function to remove nodes from network, with shiny only.
#'
#'@param graph : a \code{\link{visNetworkProxy}} object
#'@param id : vector of id, nodes to remove
#'@param updateOptions : Boolean. Update options (nodesIdSelection & selectedBy) if needed ? Default to TRUE.
#'@param legend : Boolean. Remove nodes on legend ? Default to FALSE
#'
#'@seealso \link{visNodes} for nodes options, \link{visEdges} for edges options, \link{visGroups} for groups options,
#'\link{visLegend} for adding legend, \link{visOptions} for custom option, \link{visLayout} & \link{visHierarchicalLayout} for layout,
#'\link{visPhysics} for control physics, \link{visInteraction} for interaction, \link{visNetworkProxy} & \link{visFocus} & \link{visFit} for animation within shiny,
#'\link{visDocumentation}, \link{visEvents}, \link{visConfigure} ...
#'
#' @examples
#'\dontrun{
#'
#'# have a look to :
#'shiny::runApp(system.file("shiny", package = "visNetwork"))
#'
#'}
#'
#'@export
#'@references See online documentation \url{https://datastorm-open.github.io/visNetwork/}
visRemoveNodes <- function(graph, id, updateOptions = TRUE, legend = FALSE){
if(!any(class(graph) %in% "visNetwork_Proxy")){
stop("Can't use visRemoveNodes with visNetwork object. Only within shiny & using visNetworkProxy")
}
if(!is.null(id)){
if(length(id) == 1){
id <- list(id)
}
}
data <- list(id = graph$id, rmid = id, updateOptions = updateOptions, legend = legend)
graph$session$sendCustomMessage("visShinyRemoveNodes", data)
graph
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.