我對閃亮我很新,我試圖建立一個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