I'm making a Rshiny app that overlays two scatterplots on top of each other with the ability to select data to overlay but my Rshiny code is broken due to "object 'output' not found" and a general lack of coding ability.
I'm self-taught and have been trying to fix this problem for the better part of a week, so any help would be greatly appreciated.
The error's within Rstudio I receive when running line 'output$info = renderPrint({'
- Error in output$info = renderPrint({ : object 'output' not found
and when I run the line 'output$plot = renderPlot({'
- Error in output$plot = renderPlot({ : object 'output' not found
The error's within Rshiny app when running the entire app are:
- Empty plot. No points at all. No ability to select regions from the multiInput dropdown menu Rshiny appearance
Here's my library setup just in case
library(rsconnect)
library(tidyr)
library(pheatmap)
library(readr)
library(tibble)
library(ggplot2)
library(ggforce)
library(plotly)
library(reshape2)
library(shiny)
library(dendextend)
library(RColorBrewer)
library(shinyWidgets)
library(dplyr)
region1 = as.factor(c("r001[Hypothalamus - Intermediate Zone]","r001[Hypothalamus - Intermediate Zone]", "r001[Hypothalamus - Intermediate Zone]","r003[Optic tectum - neuropil]","r003[Optic tectum - neuropil]", "r003[Optic tectum - neuropil]"))
region2 = as.factor(c("r001[Hypothalamus - Intermediate Zone]", "r003[Optic tectum - neuropil]", "r004[Rhombomere 5 - Ventromedial]", "r001[Hypothalamus - Intermediate Zone]", "r003[Optic tectum - neuropil]", " r004[Rhombomere 5 - Ventromedial]"))
corvalue = as.numeric(c("1.000000000", "0.347262124", "-0.217184495", "0.347262124", "1.000000000", "-0.279342601"))
distvalue = as.numeric(c("0.0", "42.6","88.7", " 42.6", "0.0", "82.9"))
complete_vectp = data.frame(region1, region2, corvalue, distvalue)
p_names = levels(as.factor(complete_vectp$region2))
# - Forloop that is supposed to generate the separate plots
for (i in 1:length(p_names)) {
strpattern <- substr(p_names[i], 1, 4)
regionx = complete_vectp %>% #Section off by region name
filter(grepl(strpattern, region2))
#gives all the regions without the selected region
comparison_region <- complete_vectp[which(complete_vectp$region1 == p_names[i]), ]
#gives the selected region without the rest of the regions
other_regions <- complete_vectp[-c(which(complete_vectp$region1 == p_names[i])), ]
subplot = ggplot(other_regions, aes(x = distvalue, y = corvalue))
}
as.character(other_regions$region2)
ui = fluidPage(
titlePanel("something"),
sidebarLayout(
sidebarPanel(
multiInput("name", "Select Region",
choices = unique(other_regions$region1)
),
),
mainPanel(
verbatimTextOutput("info"),
plotOutput("plot")
)
)
)
server = function(input, output) {
other_regions_reactive = reactive({
other_regions %>%
dplyr::filter(unique(region1) == input$name)
})
output$info = renderPrint({
nearPoints(complete_vectp, input$plot_click, input$plot_brush, threshold = 2, maxpoints = 5)
})
output$plot = renderPlot({
ggplot(other_regions_reactive(), aes(x = distvalue, y = corvalue))
})
}
shinyApp(ui = ui, server = server)