shinyapps.IO 为 selectInput 选择的内容自定义 URL
shinyapps.IO custom URL for content selected by selectInput
我希望根据 selectInput()
选择的值在 shinyapps.IO 中生成自定义 URL(或愿意升级到适当的企业工具)。在下面的示例中,如果我发布到 shinyapps.IO,URL 将是 https://myDomain.shinyapps.io/myAppName/。
我想要 5 个独特的 URL,基于用户从 selectInput() 中选择的选项。
- https://myDomain.shinyapps.io/myAppName/Option1
- https://myDomain.shinyapps.io/myAppName/Option2
- https://myDomain.shinyapps.io/myAppName/Option3
- https://myDomain.shinyapps.io/myAppName/Option4
- https://myDomain.shinyapps.io/myAppName/Option5
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(tidyverse)
#################### UI ###################
ui <- dashboardPagePlus(
###### Header ####
header = dashboardHeaderPlus(
title = NULL,
titleWidth = '250',
disable = FALSE,
enable_rightsidebar = FALSE,
.list = NULL,
left_menu = tagList(
selectInput(
inputId = "options",
label = "Select an option",
choices = c('Option1', 'Option2', 'Option3', 'Option4', 'Option5'))
) #end left_menu
), #close Header
###### Sidebar ####
sidebar = dashboardSidebar(disable = TRUE),
footer = dashboardFooter(NULL),
###### Body ####
body = dashboardBody(
uiOutput('optionSelected')
) #close dashboardBody
) # closes Dashboard Page Plus
#################### SERVER ####################
server = function(input, output, session) {
output$optionSelected <- renderUI({
input$options
}
)
}
shinyApp(ui = ui, server = server)
我在 https://community.rstudio.com/t/vanity-urls-with-connect-via-deployapp/18927/4 上读到了关于 'Vanity URLs' 的内容,但这似乎不是我正在寻找的解决方案。
感谢任何建议。
正如我在评论中提到的,我认为您正在寻找书签,请参阅 ?shiny::enableBookmarking()
。
要添加书签,您必须对代码进行三处修改。制作
ui 代码函数
ui <- function(request){...}
在您的 ui
中添加书签 trigger/button
bookmarkButton()
启动应用程序前启用书签。
enableBookmarking("url")
最小可重现示例为:
ui <- function(request) {
fluidPage(
selectInput("options", "opt", choices = c('Option1', 'Option2')),
bookmarkButton()
)
}
server <- function(input, output, session) { }
enableBookmarking("url")
shinyApp(ui, server)
自动生成 urls
port_nr <- 3033
input_id <- "select_opt"
choices <- c('Option1', 'Option2')
paste0("http://127.0.0.1:", port_nr, "/?_inputs_&", input_id, "=",
URLencode(choices, reserved = TRUE))
你的例子应该是:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- function(request) {
dashboardPagePlus(
###### Header ####
header = dashboardHeaderPlus(
title = NULL,
titleWidth = '250',
disable = FALSE,
enable_rightsidebar = FALSE,
.list = NULL,
left_menu = tagList(
selectInput(
inputId = "options",
label = "Select an option",
choices = c('Option1', 'Option2', 'Option3', 'Option4', 'Option5'))
) #end left_menu
), #close Header
###### Sidebar ####
sidebar = dashboardSidebar(disable = TRUE),
footer = dashboardFooter(NULL),
###### Body ####
body = dashboardBody(
uiOutput('optionSelected'),
bookmarkButton()
) #close dashboardBody
) # closes Dashboard Page Plus
}
#################### SERVER ####################
server = function(input, output, session) {
output$optionSelected <- renderUI({
input$options
}
)
}
enableBookmarking("url")
shinyApp(ui = ui, server = server)
我希望根据 selectInput()
选择的值在 shinyapps.IO 中生成自定义 URL(或愿意升级到适当的企业工具)。在下面的示例中,如果我发布到 shinyapps.IO,URL 将是 https://myDomain.shinyapps.io/myAppName/。
我想要 5 个独特的 URL,基于用户从 selectInput() 中选择的选项。
- https://myDomain.shinyapps.io/myAppName/Option1
- https://myDomain.shinyapps.io/myAppName/Option2
- https://myDomain.shinyapps.io/myAppName/Option3
- https://myDomain.shinyapps.io/myAppName/Option4
- https://myDomain.shinyapps.io/myAppName/Option5
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(tidyverse)
#################### UI ###################
ui <- dashboardPagePlus(
###### Header ####
header = dashboardHeaderPlus(
title = NULL,
titleWidth = '250',
disable = FALSE,
enable_rightsidebar = FALSE,
.list = NULL,
left_menu = tagList(
selectInput(
inputId = "options",
label = "Select an option",
choices = c('Option1', 'Option2', 'Option3', 'Option4', 'Option5'))
) #end left_menu
), #close Header
###### Sidebar ####
sidebar = dashboardSidebar(disable = TRUE),
footer = dashboardFooter(NULL),
###### Body ####
body = dashboardBody(
uiOutput('optionSelected')
) #close dashboardBody
) # closes Dashboard Page Plus
#################### SERVER ####################
server = function(input, output, session) {
output$optionSelected <- renderUI({
input$options
}
)
}
shinyApp(ui = ui, server = server)
我在 https://community.rstudio.com/t/vanity-urls-with-connect-via-deployapp/18927/4 上读到了关于 'Vanity URLs' 的内容,但这似乎不是我正在寻找的解决方案。
感谢任何建议。
正如我在评论中提到的,我认为您正在寻找书签,请参阅 ?shiny::enableBookmarking()
。
要添加书签,您必须对代码进行三处修改。制作
ui 代码函数
ui <- function(request){...}
在您的 ui
中添加书签 trigger/buttonbookmarkButton()
启动应用程序前启用书签。
enableBookmarking("url")
最小可重现示例为:
ui <- function(request) {
fluidPage(
selectInput("options", "opt", choices = c('Option1', 'Option2')),
bookmarkButton()
)
}
server <- function(input, output, session) { }
enableBookmarking("url")
shinyApp(ui, server)
自动生成 urls
port_nr <- 3033
input_id <- "select_opt"
choices <- c('Option1', 'Option2')
paste0("http://127.0.0.1:", port_nr, "/?_inputs_&", input_id, "=",
URLencode(choices, reserved = TRUE))
你的例子应该是:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- function(request) {
dashboardPagePlus(
###### Header ####
header = dashboardHeaderPlus(
title = NULL,
titleWidth = '250',
disable = FALSE,
enable_rightsidebar = FALSE,
.list = NULL,
left_menu = tagList(
selectInput(
inputId = "options",
label = "Select an option",
choices = c('Option1', 'Option2', 'Option3', 'Option4', 'Option5'))
) #end left_menu
), #close Header
###### Sidebar ####
sidebar = dashboardSidebar(disable = TRUE),
footer = dashboardFooter(NULL),
###### Body ####
body = dashboardBody(
uiOutput('optionSelected'),
bookmarkButton()
) #close dashboardBody
) # closes Dashboard Page Plus
}
#################### SERVER ####################
server = function(input, output, session) {
output$optionSelected <- renderUI({
input$options
}
)
}
enableBookmarking("url")
shinyApp(ui = ui, server = server)