r-用一些包编写的代码在renderPlot函数中给出空白输出



某些包(如timetkplot_ly(的plot函数不会生成写入renderPlot函数中的plot(output)。尽管当我在控制台中运行output(plot)时,同一段代码会返回它。与plot()一样,ggplot()也起作用。为什么会这样?

这段带有timetk库的代码在rstudio控制台中提供输出:

dataset %>%
plot_time_series(.date_var = Year, .value = column1,
.interactive = TRUE, .y_lab = "Amt", .x_lab = "Year",
)

但如果在renderPlot函数中写入相同的部分,它不会在RShiny应用程序上提供输出,只是显示一个空白的白色屏幕。

UI:UI代码都很好。我也写了一本plotOutput("p1")

服务器:

output$p1 <- renderPlot({ 
dataset %>%
plot_time_series(.date_var = Year, .value = column1,
.interactive = TRUE, .y_lab = "Amt", .x_lab = "Year",
)
})

问题是renderPlotplotOutput用于基本图或ggplot。当你想制作一个交互式的plotly图表时,你必须使用plotly::renderPlotlyplotly::plotlyOutput

最新更新