checkboxGroupInputの使用方法について質問があります。データフレームから何ヶ月もの日付をフィルタリングできるフィルタを作成したいと考えています。 dplyrのフィルタ関数では、例としてc(1,2,3,4)<を使用する必要があります。これをチェックボックスのGroupInputで生成して、選択した月をggplotに表示できるようにします。checkboxGroupInput dplyrフィルタリングの値
それは次のコードで動作し:
filter(Location == input$locatie & month(Month_StartConnection) %in% c(1,2,3,4))
C(1,2,4,5)checkboxGroupInput入力で動的でなければなりません。それは実際のベースに....
を働いている場合、あなたのコードをチェックするために、実際には不可能である
おかげ
## app.R ##
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Test", tabName = "KPI", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "KPI",
fluidRow(
checkboxGroupInput(inputId = "seizoen", label = "Seizoen", choices = list("Alle Maanden", 1,2,"mrt","apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec"), value = TRUE),
selectInput(inputId = "locatie",
label = h3("Locatie"),
choices = c("Speerpunt","Museum","Strandweg", "Zwarte pad", "Prins Clauslaan", "Prinsessegracht", "Fluwelen Burgwal", "Kranestraat", "Heulstraat", "Kneuterdijk", "Hoge Nieuwstraat", "Kijkduin", "De Uithof", "Zwembad het Hofbad", "Kyocera stadion", "Stadhuis"),
selected = 1
),
plotOutput("ggplot", height = 600, width= 600)
)
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab 1")
)
)
))
server <- function(input, output) {
output$ggplot <- renderPlot({
print(
Merge_Charge_Point %>%
select(Charge_Point_ID, Location, kWh, Month_StartConnection) %>%
filter(Location == input$locatie & month(Month_StartConnection) %in% c(input$seizoen)) %>%
group_by(Month_StartConnection) %>%
summarise(aantal_sessies = n()) %>%
filter(Month_StartConnection < as.Date(format(as.Date(strptime(Sys.Date(),"%Y-%m-%d",tz="")) ,format = "%y-%m-1")))%>%
ggplot(aes(Month_StartConnection, aantal_sessies, group = 1))+
geom_line()+scale_x_date(labels = date_format("%y-%m")) +
geom_smooth(method = "lm", se = FALSE)
)
})
}
shinyApp(ui, server)
それはだから、 'あなたの代わりに、' == 'で、%'で '%を使用する必要がchecboxGroupInput':例えば、'フィルタ(%入力の$ locatieで場所%) '。これは 'checkboxGroupInput'が値のベクトルを返します – SymbolixAU
あなたの入力をありがとうが、私たちはこのコードの答えを探しています: 月(Month_StartConnection)%in%c(入力$ seizoen) –
例えば、 'choices = c(" Alle Maanden "、1,2、" mrt "、...)' – SymbolixAU