The goal of vincent is to demonstrate you how to write a tidy production-ready Shiny Application from scratch.
In order to attend this tutorial is enough to have R (>3.4), RStudio (best if it is updated) and Git installed on your computer. Dependently on you operative system you can install:
- install "Git for Windows" https://gitforwindows.org/ if you use Windows
- use your favorite package manager if you use Linux: i.e.
sudo apt install git
- should be integrated in your system if you use MacOS.
In order to test that:
- select New Project from RStudio Menu,
- Version Control
- Git
- Repository URL:
https://github.com/vanlog/vincent
- Create project
If everything works, your setup is complete. We will develop the package from scratch.
This steps are useful only to speed up the installation:
install.packages("renv")
renv::activate()
renv::restore()
I am looking forward meeting you!
- master: use it only for the
README.md
filedoc
folder anddata-raw
- stage-0: brand new Golem Project
- stage-1: status at the end of the first part
- stage-2: status at the end of the second part
- stage-3: status at the end of the third part
Example we want to start from stage-0 (we are at the beginning of the workshop):
- set the branch to stage-0 (example command:
git checkout stage-0
) - create a new branch stage-1-wip (work in progress to stage-1)
- now you can code and commit.
Example we are at the beginning of the second part and want to start from stage-1
- commit everithing or reset your git repo (no modification on the stage or not in the stage)
- set the branch to stage-1 (example command:
git checkout stage-0
) - create a new branch stage-2-wip (work in progress to stage-2)
- now you can code and commit.
Read Recipe How to install a package
Redo what I did from stage-0
. You can now use the functions we did not used during the lesson (we transfered them into commets). Read their manual and use git to understand how they modify your project.
Play around with this application implementing some shiny code in app_ui.R
and app_server.R
. You can insert an empty shiny dashboard now. Move on and play with shiny.
Some copy and paste code: https://rstudio.github.io/shinydashboard/get_started.html
Play around with renv
:
- try to install a new package with
renv::install()
orinstall.packages()
and look at the differencies. - try to install a new package with
renv::install()
, thenrenv::snapshot()
and use "git diff" to see what happens. - remove a package with
renv::remove()
and then tryrenv::snapshot()
orrenv::restore()
Play around with reactives, use also other kind of reactives.
library(shiny)
# create a new reactive value
v1 <- reactiveVal(3)
# print its content
isolate( v1() )
# copy it. Note that I do not use parenthesis.
v2 <- v1
# content is the same
isolate( v2() )
# change the content
v1(10)
# the content is changed also in the copy
isolate( v2() )
Add another dashboard-tab to the application, that reads or modifies or reads-and-modifies data1
, install packages and do whatever you want to customize your application.
Print log messages using one of the following functions:
flog.error()
flog.warn()
flog.info()
flog.debug()
flog.trace()
And play around with the threshold level:
library(futile.logger)
flog.threshold("debug")
flog.warn("warn")
flog.info("info")
flog.debug("debug")
flog.threshold("info")
flog.warn("warn")
flog.info("info")
flog.debug("debug")
flog.threshold("warn")
flog.warn("warn")
flog.info("info")
flog.debug("debug")
Continue with the development of the application trying to separate the plain R part from the shiny part. Test the plain R code.