【发布时间】:2019-02-22 11:43:39
【问题描述】:
我想根据 Date_Bucket 列对 timevis 输出图进行颜色编码,任何帮助将不胜感激。
head(file)
Record_ID Start End Date_Bucket
1 01-01-2017 31-12-2021 Greater than 2 Years
2 01-11-2013 31-10-2028 Greater than 2 Years
3 01-11-2017 31-10-2022 Greater than 2 Years
4 22-04-2014 30-09-2020 1-2 Years
5 15-12-2017 30-06-2019 0-6 Months
6 01-11-2017 31-10-2022 Greater than 2 Years
7 22-04-2014 30-09-2020 1-2 Years
8 11-01-2013 31-08-2019 6-12 Months
9 11-10-2013 31-08-2019 6-12 Months
file$Start <- as.Date(file$Start)
file$End <- as.Date(file$End)
if (interactive())
library(shiny)
shinyApp(
ui = fluidPage(
timevisOutput("timeline"),
actionButton("btn", "Fit all items")
),
server = function(input, output) {
output$timeline <- renderTimevis(
timevis(data.frame(
id = file$Record_ID, start = file$Start , end = file$End, content =
file$Date_Bucket
))
)
observeEvent(input$btn, {
fitWindow("timeline", list(animation = TRUE))
})
}
)
}
【问题讨论】: