Communicating data with interactive web apps
Lecturer: Emi Tanaka
Department of Econometrics and Business Statistics
Open-ended dialogue between the user and the computer
Image from Spencer (2022, Feb. 17). Data in Wonderland. Retrieved from https://ssp3nc3r.github.io/data_in_wonderland
Image from Spencer (2022, Feb. 17). Data in Wonderland. Retrieved from https://ssp3nc3r.github.io/data_in_wonderland
Tominski, Christian, and Heidrun Schumann (2020) Interactive Visual Data Analysis. CRC Press.
shiny
?shiny
?shinyapp
and Shift + Tablibrary(shiny) # exported from `htmltools`
tags$html(
tags$body(
h1('My first heading'),
p('My first paragraph, with some ', strong('bold'), ' text.'),
div(id = 'myDiv', class = 'simpleDiv',
'Here is a div with some attributes.')
)
)
includeCSS()
and includeScript()
to include CSS and JS filesfluidRow
+ columns
This is using bootstrap
fluidPage(
fluidRow(column(width = 4,
h3("Some informative table"),
tableOutput("mytable")),
column(width = 4, offset = 3,
h3("Fancy plot"),
plotOutput("myplot"))),
fluidRow(column(width = 12,
"Minimum width is 1 and maximum width is 12"))
)
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<h3>Some informative table</h3>
<div id="mytable" class="shiny-html-output"></div>
</div>
<div class="col-sm-4 offset-md-3 col-sm-offset-3">
<h3>Fancy plot</h3>
<div id="myplot" class="shiny-plot-output" style="width:100%;height:400px;"></div>
</div>
</div>
<div class="row">
<div class="col-sm-12">Minimum width is 1 and maximum width is 12</div>
</div>
</div>
sidebarLayout
fluidPage(sidebarLayout(
sidebarPanel(h3("User control"),
actionButton("id1", "Push")),
mainPanel(h3("Main Panel"),
plotOutput("myplot"))
))
<div class="container-fluid">
<div class="row">
<div class="col-sm-4">
<form class="well" role="complementary">
<h3>User control</h3>
<button id="id1" type="button" class="btn btn-default action-button">Push</button>
</form>
</div>
<div class="col-sm-8" role="main">
<h3>Main Panel</h3>
<div id="myplot" class="shiny-plot-output" style="width:100%;height:400px;"></div>
</div>
</div>
</div>
server | ui |
---|---|
renderDataTable |
dataTableOutput |
renderImage |
imageOutput |
renderPlot |
plotOutput |
renderPrint |
verbatimTextOutput |
renderTable |
tableOutput |
renderText |
textOutput |
renderUI |
uiOutput or htmlOutput |
reactiveValues
creates your own reactive valuesisolate
prevents reactionsreactive
caches its value to reduce computation and notifies its dependencies when it has been invalidatedobserveEvent
runs code when the first argument changesobserve
runs code when any reactive elements within it changesbrowser()
+ breaking pointsETC5523 Week 3