我对闪亮我很新,我试图建立一个Web应用程序,从GEO下载数据集或让用户上传他自己的。能够以boxplot格式和表格格式向用户显示数据,然后让用户决定是将数据进行标准化还是日志转换。我的问题是在代码后面的顺序actionButton不起作用。如果我按下第一个动作按钮,然后按第二个动作按钮,这两个都很奇怪。但是如果我选择直接按第二个动作按钮,它什么也不做。这里是我的代码:shiny - actionButton#1完全相同actionButton#2 doesnt
ui.R
library(shiny)
library(som)
shinyUI(pageWithSidebar(
# Application title
#
headerPanel("Dataset Selection"),
# Sidebar with controls to select a dataset and specify the number
# of observations to view
sidebarPanel(
actionButton("Gobutton", "Bring it up"),
fluidRow()
),
mainPanel(
tabsetPanel(
tabPanel("Dataset",
fluidRow(
column(8, uiOutput("dataTable"),
tags$style(type='text/css', '#view {background-color: rgba(11,56,49,0.2); color: black; font-family:verdana;}')))
),
tabPanel("Boxplot",
fluidRow(
column(8,plotOutput("preprocessData"),
tags$style(type='text/css', '#view {background-color: rgba(11,56,49,0.2); color: black; font-family:verdana;}'))),
conditionalPanel(condition = "input.NormalizeButton <= 0",
actionButton("NormalizeButton","Normalize")),
conditionalPanel(condition = "input.LogTransformButton <= 0",
actionButton("LogTransformButton", "Log2 Transform"))
))
)
)
)
server.R
shinyServer(function(input, output) {
library(xtable)
# You can access the value of the widget with input$num, e.g.
GSEmRNA <- data.frame(from=c(100,200,150), to=c(1000,2000,150),last= c(50,50,250))
normalizeSom <- function(GSEmRNA){
colnamesSAVE <- colnames(GSEmRNA)
GSEmRNA <- som::normalize(GSEmRNA) # Normalize the dataset using som package of R
colnames(GSEmRNA) <- colnamesSAVE
boxplot(GSEmRNA)
print(colnames(GSEmRNA))
return(GSEmRNA)
}
todoLogTransformation <- function(GSEmRNA) {
GSEmRNA <- log(GSEmRNA,2)
boxplot(GSEmRNA)
return(GSEmRNA)
}
output$dataTable <- renderUI({
input$Gobutton
if (input$Gobutton== 0) {return()}
else{
GSEmRNAprinted <- print(xtable(head(GSEmRNA), align=rep("c", ncol(GSEmRNA)+1)),
floating=FALSE, tabular.environment="array", comment=FALSE, print.results=FALSE)
html <- paste0("$$", GSEmRNAprinted, "$$")
list(
withMathJax(HTML(html)))}
})
output$preprocessData <- renderPlot({
if (input$Gobutton== 0) {return()}
else{
boxplot(GSEmRNA)
input$LogTransformButton
if(input$LogTransformButton ==0){return()}
else if(input$LogTransformButton != 0){
GSEmRNA <<- todoLogTransformation(GSEmRNA)
}
input$NormalizeButton
if(input$NormalizeButton ==0){return()}
else if(input$NormalizeButton != 0){
GSEmRNA <<- normalizeSom(GSEmRNA)
}}
})
})
还有最后一点,我想我在输出$ dataTable的<描述表 - renderUI换新各时间用户按下标准化或记录变换。任何帮助是极大的赞赏。我一直在这一段时间
这将是更容易帮助你,如果你能提供你的程序的一个非常简化的版本。尝试使用最小的库来分离问题,也许只是在这种情况下闪亮。 – Geovany
我将代码修改为更简约。感谢您的输入 –
尝试使用简单的'data.frame'来创建示例以显示您想要的内容(允许没有'GEOquery'的人试图修复它)。此外,您可能必须使用'reactiveValues'来处理数据(而不是使用'<< - ')。参见'observeEvent',它允许你改变你的'reactiveValues'编辑完成。 – Batanichek