如何解决定义要绘制的变量的函数
我想通过定义为 output$myplot1
、 output$myplot2
等的多个绘图函数绘制多个绘图,这些绘图当前在参数 selectInput
中定义,例如 {{1} } 是骨病。但是,我想使用除 p1
之外的另一个函数来定义要为 myplot1 和 myplot2 绘制哪些参数,因为我不希望它显示在侧边栏中。
如何用定义要绘制的临床参数但不在侧栏中显示的类似线替换此线:selectInput
我想在侧边栏中显示的唯一参数是 selectInput("p1","Clinical parameter",choices = c("Serum_M_component"))
。
!更新了示例输入数据。
MicroRNA
解决方法
一种方法是使用 shinyjs
包的 hidden
选项。试试这个
"Yes","Yes")),row.names = c(NA,3L),class = "data.frame")
library(shinyjs)
ui.miRNA.clinical <- dashboardPage(
# Application title
dashboardHeader(title=h4(HTML("MicroRNA expression <br/> in Multiple myeloma"))),dashboardSidebar(
useShinyjs(),selectInput("gene","MicroRNA",choices = unique(data_prep$miRNA)),shinyjs::hidden(
selectInput("p1","Clinical parameter",choices = c("Bone_disease"),),selectInput("p2",choices = c("Serum_M_component")),selectInput("p3",choices = c("ISS_stage")),selectInput("p4",choices = c("del17")),selectInput("p5",choices = c("t4_14"))
)
),dashboardBody(
tabsetPanel(
tabPanel("Plot Bone_disease",plotOutput("myplot1",width = "400px",height = "300px")),tabPanel("Plot Serum_M_component",plotOutput("myplot2",tabPanel("Plot ISS_stage",plotOutput("myplot3",tabPanel("Plot del17",plotOutput("myplot4",tabPanel("Plot t4_14",plotOutput("myplot5",height = "300px"))
)
)
)
server.miRNA.clinical <- function(input,output,session) {
# filter data by Gene
data_selected <- reactive({
filter(data_prep,miRNA %in% input$gene)
})
# Plot. use aes_string to simply use character input p
#my_comparisons <- list( c("Yes","No"),c("Stage 1","Stage 3"))
output$myplot1 <- renderPlot({
ggplot(data_selected(),aes_string(input$p1,"value",fill = input$p1)) +
geom_boxplot() + theme_classic(base_size = 12) + labs(x="Clinical parameter",y="MicroRNA expression (cpm,log2)") +
stat_compare_means(method = "wilcox.test")
#method ="anova"
})
output$myplot2 <- renderPlot({
ggplot(data_selected(),aes_string(input$p2,fill = input$p2)) +
geom_boxplot() + theme_classic(base_size = 12) + labs(x="Clinical parameter",log2)") +
stat_compare_means(method = "anova")
#method ="anova"
})
output$myplot3 <- renderPlot({
ggplot(data_selected(),aes_string(input$p3,fill = input$p3)) +
geom_boxplot() + theme_classic(base_size = 12) + labs(x="Clinical parameter",log2)") +
stat_compare_means(method = "anova")
#method ="anova"
})
output$myplot4 <- renderPlot({
ggplot(data_selected(),aes_string(input$p4,fill = input$p4)) +
geom_boxplot() + theme_classic(base_size = 12) + labs(x="Clinical parameter",log2)") +
stat_compare_means(method = "anova")
#method ="anova"
})
output$myplot5 <- renderPlot({
ggplot(data_selected(),aes_string(input$p5,fill = input$p5)) +
geom_boxplot() + theme_classic(base_size = 12) + labs(x="Clinical parameter",log2)") +
stat_compare_means(method = "anova")
#method ="anova"
})
}
shinyApp(ui.miRNA.clinical,server.miRNA.clinical)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。