R 光泽中的反应性子集划分
我试图允许用户从几个变量中选择类,然后我使用的绘图将动态地从数据帧中子集选择的类,然后绘制输出 到目前为止R 光泽中的反应性子集划分,r,shiny,subset,R,Shiny,Subset,我试图允许用户从几个变量中选择类,然后我使用的绘图将动态地从数据帧中子集选择的类,然后绘制输出 到目前为止 ui = dashboardPage(dashboardHeader(title = "NFL"), dashboardSidebar( sidebarMenu( selectInput("Year",label = "Year", choices = c("2013" = "2013", "2014" = "2014", "2015" = "2015",
ui = dashboardPage(dashboardHeader(title = "NFL"),
dashboardSidebar(
sidebarMenu(
selectInput("Year",label = "Year",
choices = c("2013" = "2013", "2014" = "2014", "2015" = "2015",
"2016"= "2016"), selected="2013")
),
dashboardBody(
fluidRow(
plotOutput(outputId = "p1"),width = 150
)
)
)
server=function(input,output) {
output$p1 = renderPlot({
ggplot(data=df, aes_string(x=df$PlayLocation, y=df$YardageResult,
color="PlayLocation"))+
geom_point()+
geom_jitter()+
labs (x = ("Play Location"), y = ("Yards Gained"))+
theme(legend.position="none")
}
)
}
shinyApp(ui=ui, server=server)
在本例中,我希望x和y变量保持不变,但仅显示所选年份的数据。我的最终闪亮应用程序将有许多不同的变量进一步子集,但这是基本前提
有什么想法吗?我已经研究了反应式,但只找到了如何基于索引进行子集的信息,而没有找到匹配因子或字符串值的信息。这将在RStudio教程()中介绍。看看
反应式。你需要这样的东西:谢谢你的帮助!这正是我想要的。