首页 > 解决方案 > 基于用户输入的可变高度渲染图

问题描述

我正在尝试根据用户输入制作可变高度的渲染图。但是,我得到错误:找不到对象“x”:

server <- function(input, output, session) {

dat5<-reactive({
  D5 %>% 
    filter(Parameter==input$analyte)})

  output$plot1 <- renderPlot({

    if (input$graph=='By subject') {
    p<-ggplot(dat5(), aes(x=TALD.hr, y=Value, col=Parameter)) +
    geom_line(aes(group = Parameter),lwd=0.9,show.legend = F) + 
    facet_wrap(as.formula(~Label),ncol=3)+
      guides(shape=FALSE, colour=FALSE)
    }

    print(p)

    x<-ifelse(input$graph=='By subject',length(unique(D5$Label)),length(unique(D5$Cycle2)))

  }, height = function() {x*100},width = 800)
}

标签: rshiny

解决方案


推荐阅读