-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.r
48 lines (40 loc) · 1.5 KB
/
server.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
shinyServer(function(input, output, session) {
# Place to store "global variables"
rv <- reactiveValues()
# First global variable: the default message when app opens
rv$message <- renderText("Hey, Jude")
# This is the Main Page that displays the main content
mainPage <- renderUI({
output$mainpagetitle <- renderText(
"This is your main page. The message is:")
# rv$message may get different messages based on user input
output$mainpagecontent <- rv$message
do.call(list,
list(
call("textOutput", "mainpagetitle")
, call("textOutput", "mainpagecontent")
))
})
# The purpose of the settings page is to change
# content/parameters from default values
settingsPage <- renderUI({
output$settingspagetitle <- renderText("This is your settings page")
do.call(list,
list(
call("textOutput", "settingspagetitle")
, call("textInput", "newmessage", "New Message", rv$message())
, call("actionButton", "ok", "Ok, back to Main Page")
))
})
# Start out with the Main Page in the mainPanel
output$mainpanelUI <- mainPage
# What should happen when user clicks to see the settings page
observeEvent(input$settings,{
output$mainpanelUI <- settingsPage
})
# What should happen when user clicks Ok, go back to Main Page
observeEvent(input$ok,{
rv$message <- renderText(input$newmessage)
output$mainpanelUI <- mainPage
})
})