我在下面有一个简单的应用程序,它显示了一个ggplot.ggplot在控制台中生成警告(参见底部图片).我想捕获警告,并在应用程序中,在情节下显示它.
这是我的代码:
library(shiny)
library(ggplot2)
ui <- fluidPage(
titlePanel("How do i output ggplot warnings? :("),
mainPanel(
plotOutput("my_plot_that_generates_warnings"),
tags$br(),
verbatimTextOutput(outputId='ggplot_warnings')
)
)
server <- function(input, output) {
messages <- reactiveValues(ggplot_warning = 'How to capture warning and display it?')
output$my_plot_that_generates_warnings <- renderPlot({
tryCatch({
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() +
geom_smooth()
}, message = function(e) {
messages$ggplot_warning <- e$message
}, warning = function(e) {
messages$ggplot_warning <- e$message
}, error = function(e) {
messages$ggplot_warning <- e$message
})
})
output$ggplot_warnings <- renderPrint({
cat(messages$ggplot_warning)
})
}
shinyApp(ui …Run Code Online (Sandbox Code Playgroud) 我有一个场景,其中我的应用程序右上角有两个按钮,并且我有一个选项卡控件,该控件跨越整个应用程序的屏幕。(基本上,两个按钮与选项卡控件中的选项卡在同一水平线上)。问题是,当我打开多个选项卡时,按钮和选项卡重叠。我不想指定网格行/列号,以使按钮位于选项卡上方。
有什么方法可以向Tab控件指定在自动启动第二行标签之前必须打开标签控件的某个区域?
换句话说,如果我的选项卡控件的宽度为X,我该如何告诉显示实际选项卡的区域它应该只占用x-15的空间。
谢谢!