【发布时间】:2017-04-15 23:35:29
【问题描述】:
这让我很痛苦。
我想 simlpy 有一个滑块输入,它需要一个日期(最好按月步进)并因此更改一个简单的 ggplot_bar。尽管我可以显示所有内容,但似乎对滑块的更改没有反应:
这是我的代码:
ui.r
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("St Thomas' Physiology Data Console"),
# Sidebar with a slider input for the number of bins
sidebarLayout(
sidebarPanel(
sliderInput("DatesMerge",
"Dates:",
min = as.Date("2006-01-01","%Y-%m-%d"),
max = as.Date("2016-12-01","%Y-%m-%d"),
value=as.Date("2016-12-01"),timeFormat="%Y-%m-%d")
),
# Show a plot of the generated distribution
mainPanel(
tabsetPanel(
tabPanel("Breath Tests",plotOutput("distPlotLactul")),
)
)
))
server.r
library(shiny)
source("S:\\Usage.R")
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
output$distPlotLactul <- renderPlot({
#Create the data
DatesMerge<-input$DatesMerge
# draw the histogram with the specified number of bins
ggplot(TotsLactul)+
geom_bar(aes(DatesMerge,fill=year))+
labs(title=paste("Num")) +
xlab("Time") +
ylab("NumP") +
theme(axis.text.x=element_text(angle=-90)) +
theme(legend.position="top")+
theme(axis.text=element_text(size=6))
})
})
【问题讨论】:
-
谢谢@PorkChop,但我的问题不同。我将日期格式化为月份没有问题,但问题更多在于图表没有通过相应地过滤日期来响应滑块
-
你能做到吗:
dput(TotsLactul)请把数据贴在这里