我正在为 R使用rbokeh 包。我在集成到一个闪亮的应用程序中取得了一些不错的结果。我现在想集成一个功能,其中dateRangeInput现在将选择图表的日期范围(它是时间序列数据)。
##necessary packages
install.packages("shiny")
install.packages("devtools")
install.packages("dplyr")
library(devtools)
devtools::install_github("ramnathv/htmlwidgets")
devtools::install_github("bokeh/rbokeh")
library(rbokeh)
library(dplyr)
library(shiny)
#example data set
james<-mtcars[c("mpg")]
james$date<-seq(from=as.Date("2013-05-16"),to=as.Date("2013-06-16"),by="days")
james$index<-1:4
#shiny app
shiny_example <- function(chart_data = james){
date_minmax <- range(chart_data$date)
shinyApp(
ui=fluidPage(
titlePanel("a plot"),
sidebarLayout(
sidebarPanel(
textInput("index","Enter the index from 1 to 16",value=1),
uiOutput("date_range")
),
mainPanel(
rbokeh::rbokehOutput("plot_cars")
)
)
),
server=function(input,output,session)
{
current_data <- reactive({
current_df <- subset(james,index==input$index)
return(current_df)
})
output$date_range <- renderUI({
plot_data <- current_data()
current_id_range <- range(plot_data$date)
return(
dateRangeInput("date_range",
"Date Range(X Axis", …Run Code Online (Sandbox Code Playgroud)