請看看reprex中的簡單Shiny應用程式。 我的想法(我正在努力用一些開關陳述句來完成它)是能夠使用側邊欄中的按鈕來選擇只顯示表格或只顯示線圖。
有人知道如何實作這一目標嗎?
library(shiny)
library(shinyWidgets)
library(tidyverse)
library(DT)
#>
#> Attaching package: 'DT'
#> 以下物件被屏蔽在'package:shiny'中:
#>
#> dataTableOutput, renderDataTable
df < - tibble(x=seq(20)。 y=seq(20))
ui <- fluidPage()
sidebarLayout()
sidebarPanel()
pickerInput("viz_type","選擇你想看的東西",
choices=(c("表格式資料"。 "線圖")),
selected="Tabular Data",
options = list(`actions-box` = TRUE。
`selected-text-format` = "count > 3"),multiple = F)
),
mainPanel()
plotOutput("myplot" ,)
) ,
DTOutput("table")
)
))
服務器 < - function(input,output) {>
compound_data <- reactive({)
df
})
output$table < - renderDT(compound_data()
myplot <- reactive({)
df1 <- compound_data()
gpl1 <- df1 %>%
ggplot(aes(x = x, y = y))
geom_point()
gpl1
})
output$myplot <- renderPlot({)
myplot()
})
}
shinyApp(ui = ui, server = server)
#> 沒有找到PhantomJS。你可以用webshot::install_phantomjs()來安裝它。如果已經安裝,請確保通過PATH變數找到Phantomjs可執行檔案。
靜態R Markdown檔案中不支持Shiny應用程式
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/318904.html
標籤:
上一篇:使用ggplot繪制散點圖

