Giter Site home page Giter Site logo

shiny-apps's Introduction

Collection of R Shiny web applications

This is a public repository of example R Shiny apps developed by Matthew Leonawicz at Scenarios Network for Alaska & Arctic Planning, at the University of Alaska Fairbanks.

If I recall correctly, I began exploring RStudio's Shiny package when I first heard of it in late 2012. Needless to say, a lot has changed since then, including not only all the alpha-release code-breaking changes I had to adjust to when making my first apps and what features and capabilities Shiny has to offer, but also simply how I go about coding apps has changed over time symbiotically with the package's continued development. None of the apps in this repository are quite that old, though a few are close. Even so, they have been maintained and updated and tweaked since then to keep with the times as necessary.

While code is available here for each app, keep in mind that this repository represents a historical trajectory of R Shiny app development that begins from a time when Shiny was in early alpha release- back when Shiny used reactive functions instead of expressions and was still based on Bootstrap 2, as just a couple examples. Several apps contained here precede many of Shiny's now most powerful and widely utilized features, though most are more than modern enough.

Nevertheless, even those apps that are much older than the rest have been maintained and occasionally updated alongside the continued development of the Shiny package, e.g., updating older apps to utilize Bootstrap 3 when the Shiny package made that transition. These apps are useful for study and exploration if you are in the process of learning Shiny and looking for something different. Just bear in mind that because of the timeline involved and working with what was available in Shiny as time progressed, all apps will not share a completely identical coding style even though they will have been updated since first created.

R Shiny apps available online

A list of apps can be found on my GitHub pages. This list is broken out roughly by generation, which provides some sense of which apps are relatively old and which are relatively new. This is also a convenient page from where you can launch each app. This repository and the app list on my GitHub page do not have a one to one correspondence, but there is plenty of overlap.

More R Shiny apps

Some apps that are designed for specific projects tend to get their own unique GitHub repository rather than be placed here among this random assortment of apps (some are duplicated here but not all). Some of these apps are publicly available as well and their code can be perused conveniently among my other project repositories.

Staying up to date

I sometimes post about new Shiny apps or app updates on our blog, but you are more likely to find new information more quickly at my twitter. This is just a lot quicker and easier for me to use for anything where a thorough blog post is not required.

Data visualization

In addition to statistical analysis, a common reason people use R and Shiny in particular is for the ability to share quality data visualizations. If you also have a broader interest in data visualization with R, I occasionally share data animations on my YouTube channel (the highly operative phrase being "time permitting").

I also have an R package on GitHub, mapmate, that I made to consolidate a suite of reproducible examples and code to show how I go about making some of my animations. The package is geared toward meeting this simple goal since I receive a lot of questions about my data videos. But if you would like to see the package broadened in its functionality and have it become something more production-level, you are welcome to contribute here.

shiny-apps's People

Contributors

brucecrevensten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shiny-apps's Issues

US daily climate app - Popover

Popovers can only be closed when clicking on the icons which open them. Make popovers close when clicking outside popover window area.

CMIP3 / CMIP5 app - Code tab

Consider including Code tab after About tab using Ace.

The app involves a lot of code externalization, so the tab may have to involve script menus, collapsible panels, etc.

CMIP3 / CMIP5 app - Main panel layout

Reorganize main panel layout so that plot options fall in one column on the left side (width 2) and the table on the right (width 10). If the plot button has not been pressed, give the table width 12 and prevent the plot options from displaying.

US daily climate app - "cannot open connection"

Likely due to stations for which there is no data, but uncertain. Best next step is to recompile a list of ACIS stationsfrom a metadata download, this time restricted to stations for which there is specifically precipitation data.

CMIP3 / CMIP5 app - Add historical model data

Add CMIP3 and CMIP5 historical annual data to the app.

Append to the projected data.

There is only one historical run whereas there are three projected scenarios. This will cause a problem. The same historical run can be appended to each scenario yielding three model runs of identical time series lengths and identical historical values.

Alternatively, treat the historical model run as a unique data set of mutually exclusive time period. The latter approach is more conducive to plotting the historical period in a unique color as well as not plotting it up to three times overlapping (in which case the last scenario plotted will display on top of the other two, making it look like the historical portion belongs to that scenario only).

However, this means when plotting multiple models (whether one or multiple scenarios), it is best to keep the historical model run similarly colored to its corresponding projected run(s). This would be easiest if the historical run was originally concatenated with each of its corresponding projected runs.

This may require some additional code to color unique historical model time series conditional on the inclusion of other models and scenarios in the plot and how they are colored. But, a significant problem remains. That is, what happens when the x-axis does not represent annual or decadal time steps but some categorical variable, for example.

I conclude the best path forward is that the projected scenario runs will each need to be concatenated with their common historical run a priori yielding a dataset of longer time series, where multiple scenarios are identical during historical years. (1) There is no point in including historical years on the plot when there is interest in comparing scenarios. (2) Models are often compared for one scenario at a time, so including the historical period in the plot across models will not be visually problematic. (3) Ease of plotting historical data will open up an opportunity to overlay alternative historical data for comparison to the GCMs, such as CRU data.

CMIP3 / CMIP5 app - submit button reactivity

Alter reactive behavior involving the data subsetting and plot generating action buttons to be in accordance with the behavior currently in effect in the ancestor app, akcan_climate app.

The first button should only subset data and not do any plotting. The button should not display in the sidebar until all conditions are met for plotting (all required fields are sufficiently filled).

The second button should only plot data. The button should not display in the sidebar until all conditions are met for plotting and a subsetted data frame exists, the first button having been pressed.

When conditions are not met, the buttons should be removed from the screen.

US daily climate app - Slider event handling

Change the behavior of the silders in the app so that they trigger their events only on letting go of the mouse button as opposed to while dragging.

Ideally, make a version of the function which handles this so that during app development I can specify if I want to add a slider which has either type of event handling.

CMIP3 / CMIP5 app - Composite models

Add a checkbox for composite models, perhaps one checkbox for each CMIP phase.

A box should only appear when multiple models in that phase are selected. When checked, the current data frame is collapsed across models by taking the mean. Existence of the checkbox should be controlled on the server side, as opposed to appearance of the checkbox on the user side.

This will ensure that a checked box does not maintain a checked status after vanishing if the user lowers selection to one model. This way, in increasing selection again to multiple models, the reappearing box is not automatically checked. And a single model will not have its name replaced with something like "n-model composite".

CMIP3 / CMIP5 app - Dropdown menu scrolling

Fix dropdown menu scrolling issue of forced scrolling in a window due to insufficient whitespace padding at the bottom of the app screen to incorporate menus near the bottom of the page once clicked and expanded downward.

US daily climate app - jquery slider

Since updating the Shiny package, I have lost the ability to use a custom slider.

the line in sidebar.R referring to my own edited copy of the file:

tags$link(rel="stylesheet", type="text/css", href="jquery.slider.min.css"),

seems to now be ignored and the default slider is loaded regardless.

CMIP3 / CMIP5 app - Home tab

Due to the complexity of the app, it should begin on a home tab, but something simple, not the About tab. Consider a light background graphic, either for the app in general or just for the main panel on the Home tab.

CMIP3 / CMIP5 app - Fill setting broken

The ggplot2 color "fill" option is broken with respect to barplots, but only for variability barplots in the variability tab. The fill setting still works for boxplots in the variability tab and for barplots in the time series tab. The affected bars, which are to have border color or fill, but not both, take border color instead of fill regardless of whether the selected color palette is of the "-fill" or "-border" type.

CMIP3 / CMIP5 app - Boxplot colors

Boxplot colors plot correctly. However, color vs. fill is hardcoded with respect to plot type (whether or not to overlay points on boxplots). This is acceptable, but the since fill color vs. border color cannot be controlled by the user for these plots, the color palette menu in the main panel should no longer contain "-fill" and "-border" options.

CMIP3 / CMIP5 app - Conditional color menus

Remove color sequence and color palette menus from the main panel when there is no grouping variable selected (all plots are one color under this condition so the menus do not apply, but currently still display while having no effects).

This pertains to all plots.

CMIP3 / CMIP5 app - Add historical non-GCM data

Begin by adding CRU data to the app.

The data should be compiled similarly to that of the GCMs such that CRU can be comparatively analyzed in the plots along with the GCMs. This will be incredibly complicated! For example, CRU has one "scenario", call it "historical", and that scenario is mutually exclusive of all the GCM scenarios. The time period for CRU is a subset of the time period of each GCM - this is as GOOD as it gets, a subset! CRU does not belong to either CMIP phase. There is nothing that inherently lends the app to plotting CRU along with GCMs in ALL the same ways. It just doesn't make sense.

Consider the following:

  1. A checkbox for toggling CRU overlay on and off when plotting strict time series data, where the x-axis is either month, year, or decade.
  2. Force time window (year slider and decade menu) to the shorter period of time common to CRU and the GCMs, which is 1901 to 2009. This will help avoid many programming problems as well as prevent idiotic interpretations of poorly constructed graphs. This may also facilitate an opening for inclusion of CRU in non-time series plots such as the scatter plot of T ~ P and plots where the x-axis represents various categorical variables.
  3. Special color for CRU (e.g., black) when grouping/coloring by model with CRU included in the comparison, to provide additional visual differentiation. This may prove to be too much of a coding hassle for the value though. Perhaps not, but not a priority.
  4. It may be prohibitive to include CRU in among the menus for GCM models, or to have a historical option in the scenarios menus. Nor would it make sense, because it would only go in one menu, and it does not belong to either the CMIP3 group or the CMIP5 group. It is best to use the checkbox option for toggling CRU on and off. Perhaps expand the meaning of this beyond time series overlay to general inclusion by merging the CRU data frame with an identically arranged/subsetted GCM data frame (requiring 2. above as well).
  5. CRU should be treated as a "model" to facilitate its interaction in plots with other models, but it should be treated as a "scenario" among scenarios. Conceivably, it should also be treated as a CMIP phase among the two CMIP phases. This may be problematic. Potentially, when compiling CRU data, it could be compiled like the GCM data following data extraction by shapefile such that Phase=CRU, Scenario=CRU, and Model=CRU redundantly. Also potentially, the data drame structure could have columns of Phase=Obs, Scenario=Historical, and Model=CRU. it is hard to anticipate how either of these will interact with the GCM data once merged.

CMIP3 / CMIP5 app - code duplication

Remove code duplication pertaining to multiple browser tabs/plot types where possible by merging portions of similar reactive expressions into standard R functions.

US daily climate app - Annotations

Consider better labeling on plot such as "first six months" and "last six months".

Consider switching NA for an inverted triangle plotting character, also without vertical jitter.

Make room for a legend.

CMIP3 / CMIP5 app - serverHead code

Move some of the code in the serverHead.R script into the non-app code that is used to prep the .RData workspace file used by the app so that more objects are created offline and more quickly and cleanly loaded by the app at launch.

CMIP3 / CMIP5 app - Subheadings below plots

Add H5 subheading text via uiOutput below plots describing the variables across which observations are pooled in a plot.

This will help with plot interpretation. It is clear from the ggplot2 plot annotation which variables are used for x and y axes, grouping, and faceting. However, any additional variables forced into a plot are pooled together with no distinction. If additional variables are pooled, it is helpful to know what they are. Although this is mentioned in the sidebar panel, this second location is ideal for printing a more meaningful sentence about them.

This is also a helpful tentative crutch for still not having this kind of information in the plot itself, where the versatility of the app makes it challenging to even determine dynamic plot titles.

CMIP3 / CMIP5 app - Model/Scenario group/facet problem

Do not allow grouping, faceting, etc. by model or scenario when the only reason one of these factors has more than a single level is because a second model (or scenario) is selected from a phase for which there is no scenario (or model) selected (which means no data are contributed to the dataset by that phase).

US daily climate app - add 'onclick' behavior to sidebar that affects tabset

Consider switching the tab programmatically by attaching a click handler to the div that surrounds the entire set of controls -- say that div is called "sidebar", then pseudocode (JQuery/Bootstrap) could be:

$('#sidebar').on('click', $('#myTab a:first').tab('show'));

(I tried assigning us both to the issue but that doesn't appear possible. But this should notify you of "my first github issue".)

Extra notes: This is not a critical feature, but worth learning from on this app. Might not be a good solution for apps with more tabs, e.g., Plot,Table,Results,Data.

Also, I anticipate some possible confusion/inefficiency as we work on these, at least initially, on account of the fact that some feature changes you suggested implementing may already be options in Shiny, and others (but not all) would actually require direct javascript and/or css tweaks.

It is also really easy to take the wrapper functions in the Shiny package, e.g., "sidebar" or whatever, and rewrite them at a higher level to just call different stuff than than do by default- we don't necessarily have to force every fix into the provided default frameworks.

CMIP3 / CMIP5 app - group variables

On the variability tab (and perhaps others) allow for the option of no grouping variable, similar to the option of no facet/force pool among the faceting options.

funding statement to be place on all marine downscaling app about pages

This project is funded by the Alaska Ocean Observing System through its cooperative agreement ##NA11NOS0120020 with the National Oceanic and Atmospheric Administration (NOAA). Work was performed by the Alaska Center for Climate Assessment and Policy(ACCAP) at the University of Alaska Fairbanks (UAF) in partnership with the Scenarios Network for Alaska and Arctic Planning (SNAP, UAF).

CMIP3 / CMIP5 app - Add time series analysis

This would more than likely go into a separate app.

Add a time series analysis tab for basic time series modeling and comparing autocorrelation structure and other properties. Considering incorporating change point analysis as well.

CMIP3 / CMIP5 app - annual boxplots

When plotting boxplots with Year selected as the x-axis variable, each boxplot group pools all years resulting in one boxplot for each group, rather than one for each group and each year.

US daily climate app - Add bootstrap collapse to sidebar

Switch out the conditional checkboxInput expressions for bootstrap collapse.

I feel like it may take both of us working on this kind of thing together because there is sort of a continuum from behind the scenes javascript and css on one end, to top level basic shiny package R wrapper functions on the other end, where a solution may fall somewhere in the middle.

From the way Shiny has been written and presented by the developers, the impression I get is that the ideal paths toward customization might involve some combination of "write your own javascript/html/css/D3/etc." and write a simple wrapper function in R, e.g., mySidebar() and use it instead of sidebar() going forward in any app.

I do this already in extremely limited ways. For example, the sidebar and mainPanel functions, which essentially define screen layout (excluding the header at the top of the browser window), are two R functions which are hardcoded to have a "span" of 4 and 8, respectively. I made alternative functions where I deleted that hard coding, and added a formal "span" argument to them, which now gives me the ability to say sidebar2(span=3) and mainPanel2(span=9) instead of being stuck with 4 and 8. That didn't involve writing my own javascript though, or even editing and then referencing alternate html, css, or javascript files from Shiny library source files.

CMIP3 / CMIP5 app - Enhance trend line/summary visuals

Primarily for the time series tab (tab 1 time series plots, not time series analysis), but also the variability tab, improve the behavior and aesthetics of the summary visuals, such as the mean line, 95% bootstrap CI box and the among-groups range bars. The first can be improved to show a modeled/fitted trend and not simply a point to point mean line, and the latter two can be confusing, especially when plotted together (accidentally looking like a boxplot when combined).

CMIP3 / CMIP5 app - Data download

Confirm that the .csv downloads are possible. The size of the full dataset, or close to full dataset when not subset down by much, may exceed the default size limit permitted by Shiny. If so, adjust the limits accordingly.

CMIP3 / CMIP5 app - Add scatterplot matrix

Add scatterplot matrix tab. This will require significant consideration of what variables to permit the user to look for correlation between, as well as how to condition the pairings displayed upon still other variables.

CMIP3 / CMIP5 app - Data swap

Structure the app so that the current datasets can be swapped for datasets with the same fields/variables but perhaps different numbers of levels per factor. For example, the app should work as expected without any need of recoding if the .RData file is swapped for one which has five spatial domains instead of four, a longer time series.

Other changes would be more problematic, such as addition of another climate variable or another CMIP phase, but these are unlikely.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.