![]() Filtering the data? Making the plots? Wiring up buttons? Inevitably, when juggling many components, you’re likely to introduce a bug by copy-pasting a line with the wrong id or getting nested parentheses out of whack. Given our app requirements, it might feel overwhelming where to start. Modules don’t just help organize your code they help you organize your thinking. Viz_monthly("arr_delay", threshhold = 10) Next, we define the plotting function that we will use to visualize a month-long timeseries of data for each metric. # year month day n dep_delay arr_delay ind_arr_delay You can override using the `.groups` argument. Ungroup() # `summarise()` has grouped output by 'year', 'month'. Mutate(ind_arr_delay = (arr_delay > 5)) %>%Īcross(ends_with("delay"), mean, na.rm = TRUE) We filter the flights data down to a single airline and aggregate the results by day. To understand the following explanation, it helps to familiarize yourself with the data. # intersect, setdiff, setequal, union library(ggplot2) # filter, lag # The following objects are masked from 'package:base': # Attaching package: 'dplyr' # The following objects are masked from 'package:stats': ![]() In this post, I walk through a toy example of building a reporting app from the flights data in the nycflights13 package to demonstrate how modules help scale basic Shiny skills. So, not only is it possible to learn modules early, it may actually be decidedly easier than the alternative depending on your frame of mind. Shiny’s tendency toward monolithic scripts and lack of function-based thinking in introductory materials felt so unlike normal R programming. If you already are an R user who likes to think and write functions and understand Shiny basics (i.e. reactivity), then modules for certain types of tasks (discussed at the end of this post) are an excellent way to up your game. ![]() ![]() Outside of work, Emily can be found sharing more code and ideas about analytics on her website, Twitter ( and GitHub ( modules are often taught as an advanced topic, but they can also be a great way for novice Shiny developers to start building more complex applications. Emily is a Senior Analytics Manager at Capital One where she leads a team building internal analytical tools including R packages, datamarts, and Shiny apps. This post by Emily Riederer is the winning entry in our recent Call for Documentation contest. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |