R语言shiny中导航栏和侧边栏的示例分析,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
包括
基本功能是侧边栏输入文本,在主界面以表格的形式展示出来,而且还可以把过程分为好几个步骤,这里用到的代码是
withProgress(message = "Steps:",value = 0,{incProgress(1/7,detail = paste0("Waitting","1")),incProgress(2/7,detail = paste0("Waitting","2"))}
ui可以简单理解为前端页面
library(shiny)
ui<-navbarPage('Pomegranate',inverse = T,collapsible = T,
tabPanel("Gene Ontology",
sidebarLayout(
sidebarPanel(width = 2,textAreaInput("text_area_list",
label = "Please input protein id, one per line",
height = "200px",
width="180px",
value="Pg00001"),
selectInput('id_type',label="Input gene-id Type:",
selected = "A",choices = c("A","B","C")),
helpText("You are!"),
numericInput("pval_cutoff",label = "pvalue-Cutoff",
value=1,min = 0.001,max=1,step = 0.001),
numericInput("qval_cutoff",label="qvalue-CutOff",value=1,
min = 0.001,max=1,step=0.001),
hr(),
helpText("After submit it may take 1-2 minutes. Check Progress bar in right side cornor"),
actionButton("submit",label = "Submit",icon=icon('angle-double-right')),
tags$hr()),
mainPanel(
helpText("Note: After submit it may take 1-2 minutes. Check Progress bar in right side cornor."),
tags$hr(),
textOutput("gene_number_info"),
tags$hr(),
DT::dataTableOutput(outputId = "gene_number_info_table")
)
)))
server可以理解为后端数据处理逻辑
server<-function(input,output){
observeEvent(input$submit,{
withProgress(message = "Steps:",value = 0,{
incProgress(1/7,detail = paste0("Waitting","1"))
text_area_input <- input$text_area_list
df<-as.data.frame(matrix(unlist(stringr::str_split(text_area_input,"\n")),ncol=1))
print(class(text_area_input))
print(text_area_input)
incProgress(2/7,detail = paste0("Waitting","2"))
output$gene_number_info<-renderText({
paste0("A","B")
})
output$gene_number_info_table<-DT::renderDataTable({
DT::datatable(df)
})
})
})
}
shinyApp(ui=ui,server=server)
看完上述内容,你们掌握R语言shiny中导航栏和侧边栏的示例分析的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。