【发布时间】:2023-02-02 17:04:33
【问题描述】:
我想根据特定选择 (V1) 的数据集中的变量数 (Column Cancer) 更改绘图的高度。我的零工输出是p,我尝试使用out <- layer_data(p, 1)获取组数,然后使用公式length(table(out$group))*50计算地块的高度,但是,所有地块都是相同的,无论我有多少类别在我的 V1 变量中。
server <- function(input, output, session) {
data_selected <- reactive({
filter(files.Vir.DNA.df.test, V1 %in% input$Taxa)
})
output$myplot1 <- renderPlot({
#data_selected() %>%
p <- ggplot(data_selected(),aes(position,rowSums, fill = Cancer)) +
geom_bar(stat="identity") +
facet_grid(Cancer~. , scales = "free_x", space = "free_x", switch = "x") +
theme(strip.text.y = element_text(angle = 0),
strip.text.x = element_text(angle = 90),
strip.background = element_rect(colour = "transparent", fill = "transparent"),
plot.background = element_rect(colour = "white", fill = "white"),
panel.background = element_rect(colour = "white", fill = "white"),
axis.text.x = element_blank(),
axis.ticks.x = element_blank()) +
labs(y="", x="", title="") +
scale_fill_manual(values=mycolors) +
theme(legend.position = "none") +
scale_y_log10(breaks=c(1,100,10000))
print(p)
out <- layer_data(p, 1)
},res = 100,width = 600, height = length(table(out$group))*50)
}
【问题讨论】:
标签: shiny