Second Shiny Training Session: Leaflet and shinydashboards
This content was presented to Nelson\Nygaard Staff for the Shiny Webinar series on Wednesday, September 9th, 2020, and is available as a recording here and is embedded below.
Refer to the linked article..
.rds
files. If you are not familiar with these, these files a binary data format that R can read and write quickly. They are great for Shiny apps because they load quickly, as opposed to an Excel file, which has to be run through the read_excel()
function and takes more time to parse. .rds
files can load nearly instantaneously for small files, and for large files offer a significant speed advantage over other formats.source()
command to load a function from a separate .R
file. It is sometimes convenient, for a variety of reasons, to build functions or script procedures in other files to be loaded into the Shiny environment. This enables you to use the same script/functions across multiple projects, and, depending upon the application design, speed up your processing if you are not defining procedures within the Shiny context. The global.R
files can be used to load functions as well, but sometimes it might be convenient to use a separate file if shared between projects.setwd()
command for when I am testing pieces of the app so that I am operating in the same directory the application will be. This can be avoided by always using RStudio Projects at the root directory of your Shiny app, but sometimes for more complex project directories (e.g., when your app is a part of a larger project) it may be useful to still use manual working directories.ui.R
, server.R
, and global.R
files for developing Shiny applications. This means your data loading and function/script loading can be happening in the global.R
file.Refer to the linked article.
session
parameter referenced in the definition function, but to use the leaflet
features you will need to reference session
.leafletProxy()
is used to change the features plotted on a leaflet map without generating a new leaflet()
object, so the extents and zoom will not re-generate. This is helpful for changing the features (or their colors, for example) on a map based on user input.leafletProxy()
is using identifiers for features. This is genuinely good practice for data analysis anyways, so make sure you have unique identifiers for each of your geographic features/observations.leafletProxy()
s,layer IDs and click events are used.Refer to linked articles.
shinydashboard
package makes some quick aesthetic and functional features of data dashboards quick to implement and customize. That said, there are times when you will want to customize the aesthetics of a dashboard more than the package will let you – in this case you may want to build some of the functions of the dashboard from scratch. For this course, we want our demo applications to be relatively simple, so I would recommend using shinydashboard
.Participants in the course have proposed their demo Shiny applications at the linked Google Sheet. Let’s have a brief discussion about what special tools people might need for their apps and what challenges you see yourself running into.
Please schedule one-on-ones with me as needed to ask questions or bounce ideas off me specific to your application. I will try to share notes out from one-on-ones that I think will be useful to multiple people.
This content was presented to Nelson\Nygaard Staff for the Shiny Webinar series on Wednesday, September 9th, 2020, and is available as a recording here and is embedded at the top of the page.