I am trying to create a network graph with the following code (see below) but I seem to be replacing each plot during the loop iteration, instead of creating a fully connected network. I am fairly new to R, any direction in the matter would be greatly appreciated!
Here is the code I a, trying to implement: `
library(shiny)
library(visNetwork)
# Define UI for application that draws a histogram
ui <- fluidPage(
visNetworkOutput("networkR"),
# verbatimTextOutput("shiny_return")
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$networkR <- renderVisNetwork({
data <- read.csv('Random.csv')
thresh = 0.00000001
filt_data <- data[data$adj.P.Val.original<=thresh,]
uniq_cmpds <-list(unique(filt_data$Group))
temp = list()
for (el in uniq_cmpds){
temp_data[[el]] <- c(filt_data[filt_data$Group==el,])
node <- data.frame(id=c(unique(temp_data[[el]]$Group),temp_data[[el]]$Shown.ID),
label=c(unique(temp_data[[el]]$Group),temp_data[[el]]$Shown.ID),
color=c('lightblue',c(rep('purple',times=length(temp_data[[el]]$Shown.ID)))))
edges <- data.frame(from=c(temp_data[[el]]$Group), to=c(temp_data[[el]]$Shown.ID))
}
visNetwork(node,edges)
})
}
# Run the application
shinyApp(ui = ui, server = server)
`