我是R的新手。基本上,我是在一页的发光仪表板中创建动态向下钻取数据表,在其中必须显示df w.r.t的status
变量的数量
1)id
2)ID和日期
3)id和小时
4)id,日期和小时
5)以上所有因素均以status
进行检查,
6)单因素status == red
或绿色,黄色
7)组合因数与or和and条件
我有一个概念,要添加两个input boxes
(week_of_day和hour_hand)。在这两个框中输入一些值时,将相应地更改该值。
也欢迎任何其他方式。
谢谢。
set.seed(123)
df <- data.frame(id = sample(c(rep(seq(1:7), 15))),
day = sample(rep(c("mon", "tue", "wed","thrus","fri"),21)),
hour = round(rep(runif(105,0,24)),0),
status = sample(rep(c("red", "green", "yellow"), 35)))
df_id <- dcast(df, id~status)
df_day <- dcast(df, id+day ~ status)
df_hour <- dcast(df,id+hour ~ status )
df_day_hour <- dcast(df,id+day+hour ~ status)
ui <- dashboardPage(skin = "red",
dashboardHeader(title = "Id_call"),
dashboardSidebar(sidebarMenu(menuItem("Views", tabName = "tab_01", icon =icon("bar-chart")))),
dashboardBody(tabItems(
tabItem(tabName = "tab_01",
fluidRow(column(2, selectInput("day_of_week",
"Week day:",
c("All", unique(as.character(df_id$week_day))))),
column(2, selectInput("hour_hand",
"Hour:",
c("All",1:24))))
))))
server <- function(input, output){
output$table_01 <- renderDT(datatable({if_else(input$)
dcast(df,id~Status)
if (input$day_of_week != "All" & ) {
data <- data[data$ == input$,] #Lost here in using nested ifs condition in selecting dfs
}
}))}
shinyApp(ui,server)