Imagine that your browser link looks something like this: 127.0.0.1:6316/?data=pressure&name=obinna&num=50&outt=wowowow
What if you’d like the transfer the value of data and name and num to a shiny input, and the value of outt to a shiny output. That can be accomplished using shinyStorePlus’ latest version.
Here is how you do it …
Below is the code for an application to which we will integrate the shinyStorePlus package
# library
library(shiny)
if(interactive()) {
ui <- fluidPage(
  # Application title
  titlePanel("Transfer browser link parameters to shiny input"),
  # Sidebar with a slider input for number of bins
  selectInput(
    inputId = "datasetbin",
    label = "Choose an option",
    choices = c("rock", "pressure", "cars")
  ),
  textInput(
    inputId = "cd323",
    label = "Choose a name",
    value = "No name"
  ),
  numericInput(
    inputId = "number1",
    label = "Choose a number",
    value = 10
  ),
  
  htmlOutput("outputnum")
)
server <- function(input,output,session) {
}
shinyApp(ui = ui, server = server)
}shinyStorePlus 0.8 R
packageThe shinyStorePlus package is available on CRAN and can be installed as shown below
install.packages(shinyStorePlus)
Attach library
library(shinyStorePlus)
Now, the code you have should look like this …
# library
library(shiny)
library(shinyStorePlus)
if(interactive()) {
ui <- fluidPage(
  # Application title
  titlePanel("Transfer browser link parameters to shiny input"),
  # Sidebar with a slider input for number of bins
  selectInput(
    inputId = "datasetbin",
    label = "Choose an option",
    choices = c("rock", "pressure", "cars")
  ),
  textInput(
    inputId = "cd323",
    label = "Choose a name",
    value = "No name"
  ),
  numericInput(
    inputId = "number1",
    label = "Choose a number",
    value = 10
  ),
  
  htmlOutput("outputnum")
)
server <- function(input,output,session) {
}
shinyApp(ui = ui, server = server)
}You must now initialize for the package to work. Its as simple as
inserting the function below within the fluidPage()
initStore()
Now, the code you have should look like this …
# library
library(shiny)
library(shinyStorePlus)
if(interactive()) {
ui <- fluidPage(
  
  #Initialize shinyStorePlus
  initStore(),
  
  # Application title
  titlePanel("Transfer browser link parameters to shiny input"),
  # Sidebar with a slider input for number of bins
  selectInput(
    inputId = "datasetbin",
    label = "Choose an option",
    choices = c("rock", "pressure", "cars")
  ),
  textInput(
    inputId = "cd323",
    label = "Choose a name",
    value = "No name"
  ),
  numericInput(
    inputId = "number1",
    label = "Choose a number",
    value = 10
  ),
  
  htmlOutput("outputnum")
)
server <- function(input,output,session) {
}
shinyApp(ui = ui, server = server)
}Match the Shiny input IDs to paramters in the link.
Now, the code you have should look like this …
# library
library(shiny)
library(shinyStorePlus)
if(interactive()) {
ui <- fluidPage(
  
  #Initialize shinyStorePlus
  initStore(),
  
  # Application title
  titlePanel("Transfer browser link parameters to shiny input"),
  # Sidebar with a slider input for number of bins
  selectInput(
    inputId = "datasetbin",
    label = "Choose an option",
    choices = c("rock", "pressure", "cars")
  ),
  textInput(
    inputId = "cd323",
    label = "Choose a name",
    value = "No name"
  ),
  numericInput(
    inputId = "number1",
    label = "Choose a number",
    value = 10
  ),
  
  htmlOutput("outputnum")
)
server <- function(input,output,session) {
  # for the inputs
  link2input(
    #example: shiny element ID = link parameter
    cd323 = "name",
    datasetbin = "data",
    number1 = "num"
    )
  #for the outputs
  link2input(
    outputnum = "outt",
    inputtype = "output"
  )
  
}
shinyApp(ui = ui, server = server)
}Paste the final R code into your console and run. When the Shiny link launches, it may look something like this ” 127.0.0.1:6316 ”
Now, you must include the parameters in the browser link to see the magic happen. So now, you can transform that link into ” 127.0.0.1:6316/?data=pressure&name=obinna&num=50&outt=wowowow ”
That will work!
Documentation: https://shinystoreplus.obi.obianom.com Code and report issues: https://github.com/oobianom/shinyStorePlus/issues