R Shiny - Passing User Input as Global String
up vote
0
down vote
favorite
How do I take in a user input and store as environment string in server.R?
Here's an example (which produces an error):
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- as.numeric(renderText(input$n))
output$count_new <- renderText(count/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
r shiny render reactive
add a comment |
up vote
0
down vote
favorite
How do I take in a user input and store as environment string in server.R?
Here's an example (which produces an error):
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- as.numeric(renderText(input$n))
output$count_new <- renderText(count/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
r shiny render reactive
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How do I take in a user input and store as environment string in server.R?
Here's an example (which produces an error):
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- as.numeric(renderText(input$n))
output$count_new <- renderText(count/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
r shiny render reactive
How do I take in a user input and store as environment string in server.R?
Here's an example (which produces an error):
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- as.numeric(renderText(input$n))
output$count_new <- renderText(count/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
r shiny render reactive
r shiny render reactive
asked Nov 10 at 17:40
kquach
427
427
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Found the solution. Key is to use reactive
in front of input. The variable can then be called followed by ()
.
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- reactive(input$n)
output$count_new <- renderText(count()/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Found the solution. Key is to use reactive
in front of input. The variable can then be called followed by ()
.
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- reactive(input$n)
output$count_new <- renderText(count()/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
add a comment |
up vote
0
down vote
Found the solution. Key is to use reactive
in front of input. The variable can then be called followed by ()
.
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- reactive(input$n)
output$count_new <- renderText(count()/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
add a comment |
up vote
0
down vote
up vote
0
down vote
Found the solution. Key is to use reactive
in front of input. The variable can then be called followed by ()
.
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- reactive(input$n)
output$count_new <- renderText(count()/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
Found the solution. Key is to use reactive
in front of input. The variable can then be called followed by ()
.
library(shiny)
# Define the UI
n <- 100
ui <- bootstrapPage(
numericInput('n', 'Number of obs', n),
textOutput('count_new')
)
# Define the server code
server <- function(input, output)
count <- reactive(input$n)
output$count_new <- renderText(count()/10)
# Return a Shiny app object
shinyApp(ui = ui, server = server)
answered Nov 10 at 18:15
kquach
427
427
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241685%2fr-shiny-passing-user-input-as-global-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown