RShiny应用报错'object output not found'及图表、选择功能异常求助
RShiny应用开发问题求助
问题概述
我正在开发一个可叠加两个散点图且支持选择数据进行叠加的RShiny应用,但代码出现问题,提示“object 'output' not found”。作为自学编程的新手,我已花费近一周时间尝试修复该问题,恳请提供帮助。
单独运行代码行的报错
- 运行
output$info = renderPrint({时,报错:Error in output$info = renderPrint({ : object 'output' not found - 运行
output$plot = renderPlot({时,报错:Error in output$plot = renderPlot({ : object 'output' not found
运行完整应用的问题
- 图表为空,无任何数据点;multiInput下拉菜单无法选择区域
库配置及完整代码
加载依赖库
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)
内容的提问来源于stack exchange,提问作者Kyle B
相关产品推荐
相关产品推荐

