Skip to content
Snippets Groups Projects
Commit 53492e40 authored by Tom Rushby's avatar Tom Rushby
Browse files

How to shiny tutorial (WIP)

parent 157845b9
Branches
No related tags found
No related merge requests found
---
title: "shinyTutorial"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Setup and required packages
Making API requests requires the following packages: `httr` and `jsonlite`. We can install/load these using our `loadLibraries` function (in our `woRkflow` package).
```{r libraries, message = FALSE, warning = FALSE}
library(woRkflow) # remember to build it first :-)
woRkflow::setup() # load env.R set up the default paths etc
reqLibs <- c("httr",
"jsonlite",
"knitr",
"tidyr",
"data.table", # data munching
"here", # here
"lubridate", # dates and times
"ggplot2", # plots
"bookdown" # for making reports (should also install knittr etc)
)
# load them
woRkflow::loadLibraries(reqLibs)
```
## Shiny apps and documents
Two types of Shiny implementation:
* Shiny app - a web appliacation based on R code
* Shiny document - an R Markdown document that can include dynamic elements by incorporating Shiny objects
### Layout
https://vimeo.com/rstudioinc/review/131218530/212d8a5a7a/#t=1h36m51s
Using the layout function produces html(as with tags$) .
Rows:
e.g. `fluidRow()` creates `<div class="row"></div>`
Each new row is placed beneath the previous one.
Columns (12 units wide - use arguments `width` and `offset` to control size and position):
e.g. `column(width = 2)` creates `<div class="col-sm-2"></div>`
`tags$h1()` # heading text (lvl 1) - use h1 to h6
`tags$p()` # paragraph
`tags$strong()`, `tags$em()` #
`tags$hr()` #
`tags$img()` # insert image - see <https://vimeo.com/rstudioinc/review/131218530/212d8a5a7a/#t=1h45m30s>
## Deployment
To deploy both apps and documents. Same process?
See bookdown site for deploying Shiny documents.
<https://bookdown.org/yihui/rmarkdown/shiny-deploy.html>
### shinyapps.io
Using shinyapps.io
https://vimeo.com/rstudioinc/review/131218530/212d8a5a7a/#t=0h30m45s
For example:
```{r}
rsconnect::deployApp('/Users/twr1m15/SotonGitLab/woRkflow/howTo/shiny/App', appName = "gridforecast",appTitle = "GB Grid Electricity Carbon Intensity Forecast Visualisation")
```
### RStudio connect
### Other methods
Other options are available: <https://www.r-bloggers.com/deploying-r-shiny-apps-using-shinyproxy-on-windows-10-2/>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment