我试图根据用户输入使renderPlot的高度可变。但是,我得到错误:找不到对象“ 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)
}