我正在尝试创建一个包含仪表盘的Shiny Dashboard。这些图取决于用户选择的输入类型。例如,让我们按以下方式获取数据。
d <-
data.frame(
year = c(1995, 1995, 1995, 1996, 1996, 1996, 1997, 1997, 1997),
Product_Name = c(
"Table",
"Chair",
"Bed",
"Table",
"Chair",
"Bed",
"Table",
"Chair",
"Bed"
),
Product_desc = c("X", "X", "X", "Y", "Y", "Y", "Z", "Z", "Z"),
Cost = c(1, 2, 3, 4, 2, 3, 4, 5, 6)
)
这是我用来生成图形的以下代码。每年。使用facet_wrap在Facets中显示每年的数据。
d %>%
ggplot(aes(Product_Name, Cost)) +
geom_col(aes(fill = Product_desc), position = position_dodge(preserve = "single")) +
facet_wrap(~year, scales = "free_x", strip.position = "bottom") +
theme(strip.placement = "outside") +
theme_bw()
我希望将数据显示在闪亮的仪表板中的单独页面中或单独的选项卡中,而不是将年份数据显示在构面上。
例如,如果用户仅选择2年,则第一张图应显示在一页中,第二张图应显示在下一页中。例如,如下图所示。
根据选择的年份,应该有相同数量的页面/选项卡显示每年的图表。
有人可以建议我如何继续进行。
如果需要其他任何信息,请告诉我。
谢谢。
大卫。