我已經寫了一個R閃亮的應用程序,之前只有一個按鈕被點擊後才顯示一個圖。由於某種奇怪的原因,我不能得到下面的代碼,在點擊按鈕後輸入renderPlot
函數(即單擊按鈕時永遠不會到達browser()
),我很難過。請成爲我的第二雙眼睛,我確信我錯過了一些微不足道的東西。R Shiny - plotOutput內聯和大小參數可以防止輸入渲染圖
observe
功能正常工作,並更新selectizeInput
就像我想要的。導入csv也可以正常工作,我也可以使用DT::renderDataTable
來顯示它。
您可以使用this爲例的數據,但它不應該的問題,因爲我的代碼沒有繪製任何東西
服務器
rm(list = ls())
library(shiny)
library(leaflet)
library(DT)
library(stringr)
library(zoo)
options(shiny.maxRequestSize=30*1024^2)
TAG_COL <- 1
TIME_COL <- 2
DATE_COL <- 3
ACTION_COL <- 4
HEADFIX_STR <- 'reward0'
shinyServer(function(input, output, clientData, session) {
inFile<-reactive({
input$file1
if(is.null(input$file1)){
return(NULL)
}
else{
inF<-read.csv(input$file1$datapath, header=input$header, sep=input$sep, quote=input$quote)
inF
}
})
observe({
if(!is.null(inFile)){
updateSelectizeInput(session, "tagChooser",
'Choose Tags to plot',
choices = unique(inFile()[[TAG_COL]]))
}
})
# Subset between start and end with bin column and selected mice
subsetTable<-reactive({
browser()
# More code to come
})
# Plot histrogram of times between headfixes
# TODO: assumes all mice in same cage. Fix to make it work for a selection of mice from seperate cages
output$plotHist<-renderPlot({
input$goButton
browser() # <-- Why is this browser() never reached after clicking the button?
isolate({
subsetTable()
subsetHeadfixes<-subsetTable()
# More code to come
})
})
})
UI
rm(list = ls())
# Immediately enter the browser/some function when an error occurs
# options(error = some funcion)
library(shiny)
library(DT)
shinyUI(fluidPage(
titlePanel("MurphyLab"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv')),
checkboxInput('header', 'Header', TRUE),
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
','),
radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"'),
selectizeInput('tagChooser', 'Choose Tags to plot', choices = c("data not loaded"), multiple = TRUE),
textInput("abs_start","Insert start date and time. Format: %Y-%m-%d %H:%M:%S",value="2015-06-15 01:00:00"),
textInput("abs_end","Insert end date and time. Format: %Y-%m-%d %H:%M:%S",value="2015-08-15 01:00:00"),
textInput("binning", "Binning in seconds",value = 86400),
actionButton("goButton", "Plot")
),
mainPanel(
plotOutput("plotHist", inline = TRUE,width='auto',height='auto')
)
)
)
)
UPDATE:
因此,當我在012中更改plotOutput
呼叫到plotOutput("plotHist")
一切按預期工作。我正在改變我的問題,而不是:爲什麼這會解決問題?此外,只有inline
設置爲FALSE不能解決問題。
的文檔inline狀態:
使用內聯(跨度())或塊容器(DIV()),用於輸出