Volume 2, September 2020
Developing R Shiny Web Applications for Extension Education
Matthew S. Elliott
a
and Lisa M. Elliott
a
a
South Dakota State University
JEL Codes: A22, A29, Q13
Keywords: Agribusiness, data analytics, extension, R Shiny, R Markdown, web applications
1 Introduction
All producers are realizing that agriculture is now a data-driven industry, said Daniel Schmoldt,
a program leader at the National Institute of Food and Agriculture. They need to adopt as much
technology as they can to both collect and analyze data. (Pattani 2016, para. 5)
The agriculture sector is increasingly gathering and analyzing more data. Indeed, every stage along the
supply chain is generating an increasing amount of new data in real time from the sensors on planting
equipment and combines; to imagery from satellites; and scanners used by food retailers to name a few.
The gathering of real-time data has also altered the demand for high-speed analysis that can support
optimal decision making in agribusinesses (Pattani 2016). To help agribusinesses remain competitive,
extension educators can harness the recent developments in web applications to meet the new demand.
Although some of the same techniques for educating students to develop their own data analytics
can be applied to extension audiences, many want extension educators to provide the latest data analytic
methods and only the results. Indeed, many do not have the time to learn to code, understand application
programming interfaces (APIs), or how to build, estimate, and test the latest data analytic models using
the data extension audiences have at their disposal. This article discusses using R shiny web applications
to disseminate real-time data analytics to an extension audience. We outline some strategies and
resources to begin developing and using web applications for extension education.
To meet the new demand for data analytics across a broad extension audience, we have focused
our efforts on developing R shiny web-based applications (https://shiny.rstudio.com/) that incorporate
contemporary, sophisticated methods and models. R is a common, open-source programming language
used by many agricultural and applied economists. With the Shiny package in R, the data analytics that
are done can be disseminated to a broad audience. Extension specialists can also use R markdown
(https://rmarkdown.rstudio.com/) to disseminate analytics with limited interactivity in web pages and
documents. As an example, we used Shiny web applications for agricultural producers to analyze policy
and marketing decisions (e.g., Elliott et al. 2018; Elliott and Elliott 2020) and to understand the nuances
of measuring tariff impacts (Elliott and Elliott 2019). By developing web applications, we can empower
agricultural producers to use the latest data analytics methods and avoid having to teach complex topics
and jargon.
Abstract
The agriculture sector has entered a new era wherein every stage of the supply chain involves
gathering an increasing amount of data. Most of these data are generated in real-time and require rapid
analysis that can support optimal decision making for agribusinesses to remain competitive.
Consequently, extension audiences are demanding more sophisticated, rapid analysis to aid their
decision making using the data they have at their disposal. This paper discusses using R Shiny web
applications to meet the new demand.
Teaching and Educational Methods
Commentary
Volume 2, September 2020
2 Strategies and Resources for Developing Agricultural Data Analytics via
Web Applications for Extension Audiences
2.1 Degree of User Interactivity
Web applications can range in complexity and interactivity for the user. The developer of a web
application can choose to allow a limited amount of user input, or interactivity, and design the web
application to focus on clear communication of results of a predetermined analysis. The results in a web
application of this type do not have to be a static analysis, however. Rather, the web application can
update in real-time to maintain relevancy to the user (e.g., flex dashboards in R Markdown). An extension
product with limited user interactivity can be developed in R Shiny, but it may be easier to implement
this type of product using R markdown. This type of web application is often designed so a broad
extension audience can understand how to use and interpret the application without additional
education or supplementary resources. However, HTML text, logos, figures, and data tables can
accompany the analytics to communicate the analytics extensively.
Alternatively, web applications can also allow users to input their data and change modeling
assumptions, conduct sensitivity analyses, or change the model itself. This type of web application can
allow the user to understand the effect better, and the impact that modeling assumptions have on firm
specific results. These types of web applications often require users to gain additional education to best
use the web application. Additional training can be delivered through articles, workshops, webinars, or
help videos that accompany the web applications.
2.2 Enable Contemporary Methods, Models, and Visualizations
Web applications and web computing can be a game-changer for extension educators. Specifically, web
applications enable the sharing of applied research that allows for more flexibility in methods used and to
communicate the complexity of analysis better. This same flexibility is not generally available when
publishing extension articles or when developing Excel\macro workbooks. Web applications can also
provide more transparency in research to stakeholders, fostering trust, and the use of applied research to
make management and policy decisions. Moreover, user-friendly web applications can better reach a
broader audience with limited attentiveness.
Web applications empower users to have access to the latest data and analytic methods and allow
them to interact with a model in real-time to generate firm-specific results. For example, web
applications can employ deep learning image recognition to identify plant species from smartphone
photos (e.g., Lam n.d.), assess pasture potential using quantile regression (e.g., Woodward n.d.), or
provide a learning application to teach the basics of machine learning and multivariate methods to
analyze data (e.g., Nijs n.d.).
There are numerous new machine learning and visualization packages that are available through R
and Python that can be incorporated into R shiny web applications for users to apply the latest data
analytics to their particular problem. A summary of the latest machine learning methods available for R
has been described by Lesmeister (2019). Also, R shiny can use the latest mapping and plotting javascript
tools available through data analytics firms such as Plotly (https://plotly.com/r/), Leaflet
(https://rstudio.github.io/leaflet/), and Mappbox (https://plotly.com/r/mapbox-layers/).
2.3 Reaching Mobile and Tablet Users
Web applications are beneficial in that they can be used on PCs, Macs, tablets, and smartphones. A recent
study by the Pew Research Center found that 37 percent of Americans now go online, mostly using a
smartphone (Anderson 2019). Indeed, 35 percent of the users visiting our web applications have used a
mobile phone or a tablet. As extension audiences continue to view more of their content on mobile
phones and tablets, it becomes increasingly necessary to optimize extension educational materials to be
Volume 2, September 2020
delivered through these devices. R shiny web applications automatically scale to various screen sizes.
However, some web applications are more challenging to navigate and use on small mobile screens. A
promising recent package, shinyMobile (https://rinterface.github.io/shinyMobile/), has been made
available to provide shiny Apps with a more user-friendly mobile look and standalone capabilities. A
shiny application using the shinyMobile framework can appear similar to native iOS and Android
applications (e.g., Granjon, Coene, and Rudolf 2019).
2.4 Resources to Get Started Developing Web Applications
Developing web applications using R and Shiny is not difficult for extension professionals with a
background in R already. However, for users with no background using R, the learning curve to develop a
basic application applied to an extension problem may be steep.
There is an increasing amount of resources available to help extension educators begin developing
web applications. Some resources reduce the need for extension educators to become proficient coders to
develop interactive web applications or dashboards (e.g., Plotly Dash). Other open-source resources
allow for extension educators access to web application codes to use as templates that can be adapted to
their particular problem (e.g., github.com). There are several recent books on web application
development using R Shiny. For example, Web Application Development with R Using Shiny by Chris
Beeley and Shitalkumar Sukhdeve (2018), Interactive Web-Based Data Visualization with R, Plotly, and
Shiny by Chris Sievert (2020), and Hands-on Dashboard Development with Shiny: A Practical Guide to
Building Effective Web Applications and Dashboards by Chris Beeley (2018) . Updates and other
information can be found on R pubs (rpubs.com) to gain ideas and view web application designs from
other developers. There are also online training courses that developers can enroll in to learn R and web
application development using Shiny (e.g., Udemy and Datacamp).
2.5 Publishing Web Applications
Once a developer has created a web application, it can be hosted on a server. Numerous cloud computing
services allow web applications to be hosted with generally reasonable rates based on use. The default
publishing site for R Shiny apps is shinyapps.io (https://www.shinyapps.io/). Developers can register
and host five apps, with 25 active hours per month for free. Additional abilities, like faster servers,
custom URLs, more active user time, and hosting more applications, requires a paid subscription.
Developers can also purchase the Rstudio connect server software
(https://rstudio.com/products/connect/) and host their applications on their server or a university
server.
3 Examples of Shiny Web Applications We Have Developed
3.1 Ag Land Highest and Best-Use Web Application
We have developed several R Shiny applications in the past for extension education. For example, the Ag
Land Highest and Best Use Web Application was developed to disseminate ag land assessment analyses
to policy makers and stakeholders. Specifically, we quantified the probability of cropland or noncropland
use of agricultural land for property tax assessment (see http://agland.sdstate.edu/HBU/; see Figure 1).
The analysis explored what the impact would be on the state and county if there were a change in
assessment policy for ag land. A specific policy impact we explored was the change to ag land
assessments if the highest and best use was determined by how the property was used rather than basing
the assessment using the USDA-NRCS land capability classification system. The layout of this application
was a fluid page design with a navigation bar (i.e., Navbar Page) at the top to allow users to move
between different web pages with different content. The maps used in this web application were soil
raster maps with high resolution (10 square meters) and were displayed using R leaflet. The raster maps
Volume 2, September 2020
Figure 1. South Dakota State University Ag Land Highest and Best Use Study Web Application
were large files, and loading times took longer for this application to begin. One of the policies explored in
the study and reported in the web application used a random forest regression (a machine learning
technique) to determine the probability of cropland use based on soil, climate, topography, and location.
A recent web application we developed following the Ag Land Highest and Best Use was targeted to
county assessors and stakeholders who use the soil data to make ag land assessments. This application
allows users to view baseline ag land assessment data. Users are also provided with additional data and
automated notes on soil attributes to study areas where adjustments to baseline assessments may be
necessary (see https://agland.sdstate.edu/Soil_Tables/). In this application, spatial points were used
instead of raster maps to decrease the loading time for users. Further, we have made this application
more mobile- and tablet-friendly by using the shinyMobile package (see Figure 2). The ag land assessment
data associated with each point is displayed when the user hovers their finger or mouse pointer over the
map points. This web application also has an embedded interactive document made using R markdown
explaining the data and methods in more detail (see Figure 3).
Both applications allows users to select a county and variable of interest such as the assessed value;
the percent soil that has been cropped; representative yields; the percent of sand, silt, and clay in the
topsoil; and the expected animal units monthly the ag land can support. Spatial maps are displayed with
color-coded results for each county. The web application allows the users to pan in and out and to select
different base maps such as a satellite map, a road map, or a topography map.
3.2 “Nowcast” Tariff Impact Estimates Web Application
Another web application we have developed examines real-time Chinese tariff impact estimates on the
prices of U.S. agricultural commodities that can be monitored with changes in market events (see
http://agland.sdstate.edu/Tariff/). Market data are collected using an API license with Thomson Reuters
Eikon. The data are periodically updated for users to generate new “nowcasts” of tariff impacts using
commodity prices in alternative markets; latest supply and demand estimates from USDA; and relevant
currency and transportation rates. The application allows users to examine a certain commodity and
Volume 2, September 2020
Figure 2. South Dakota State University Ag Land Soil Tables App Map Tab on an iPad Mini
market (e.g., futures or cash markets), and user specified date range, as well as the ability to change
model variables to analyze the tariff impact using a Bayesian Structural Time Series model. The layout of
this application uses shinyDashboard (https://rstudio.github.io/shinydashboard/). Results are shown in
a graph, and quantified loss values are provided in information boxes above the chart (see Figure 4).
Below these results is a description of the method used, an explanation of what is being reported, a
detailed analysis, and model reports that are provided by the R packages used to do the analysis. Users
can make changes to the model and perform sensitivity analyses of variables used in the model. For
Volume 2, September 2020
Figure 3. South Dakota State University Ag Land Soil Tables App Methods Tab on an iPad Mini
example, users can include different world grain prices in the model to understand the impact on U.S.
prices from tariffs. We advise that discretion must be applied when determining which components to
make interactive for users. This particular application is more flexible than most and allows the user to engage in
model building and testing. This web application can easily be redesigned to limit user flexibility, but we were
using the application to understand the sensitivity of different models on tariff impact estimates. We found the
application useful for explaining the complicated nature of understanding tariff impacts to multiple users,
including students, and to allow sensitivity testing of models.
Volume 2, September 2020
Figure 4. South Dakota State University Tariff Impact Web Application
Web applications can also be embedded in a web page to allow developers to write an
accompanying article using common web formatting languages. For example, we created a separate
webpage using R markdown where we described the context of the tariff web application we described
above. The article was written using HTML and the web application was embedded into the report to
allow users to interact with the web application without having to leave the article (see
http://agland.sdstate.edu/Tariff_web/).
3.3 Interactive ChartsWeb Documents and PowerPoint Presentations
In addition to interactive web applications, interactive charts are becoming more widely available to
include in extension products so users can further interact with the chart as they are listening to an
extension presentation or while reading a web article. Numerous firms are offering interactive chart
hosting where the charts can easily be embedded. Some examples of these types of charting services are
Plotly, Tableau, and Google Charts. For instance, we have created interactive grain basis charts and maps
for South Dakota that can be found at http://agland.sdstate.edu/Basis/ and
http://agland.sdstate.edu/Basis2/ using R Shiny and Plotly. These charts are standalone applications
viewable on a smartphone (see Figures 5 and 6), and are embedded in HTML presentations we have
given, and in extension articles on the web (e.g., see https://extension.sdstate.edu/south-dakota-grain-
basis-tools).
3.4 Challenges with Excel
We initially tried to accomplish real-time data analytics products for extension audiences using Excel
workbooks coupled with macros to feed in real-time data. However, we quickly realized the many issues
associated with Excel when hosting producer workshops. Some problems emerged because producers
experienced trouble utilizing the tool on their home computers (e.g., because of limited memory space,
compatibility issues across different Excel versions, and an inability to use the decision tool on Macs).
Also, as the Excel-based decision tools became more complex, increasing issues emerged because of the
number of complicated steps that were conditional on the user entering accurate input in the previous
Volume 2, September 2020
Figure 5. South Dakota State University Basis Map on an iPhone 8+
step. Given web applications functionality, user-friendliness, and compatibility with smartphones and
tablets, we determined web applications were a more viable vehicle for disseminating applied research
to extension clients that use more sophisticated, real-time data analytics.
Volume 2, September 2020
Figure 6. South Dakota State University Interactive Corn Basis Chart on an iPhone 8+
4 Takeaways from Agricultural Data Analytics via Web Applications for
Extension Audiences
1. Spend adequate time designing the web application based on different requirements: educational
learning, accessibility; whether the tool will be accessed mostly on a desktop, mobile, or tablet; and
the degree of user-friendliness that is needed. Designing the application is often the most
cumbersome, time-consuming process that requires a lot of trial and error.
Volume 2, September 2020
2. Take plenty of time to beta test the web applications. As applications become more complex, bugs
and glitches are common. Also, be aware if the application does not have the same performance
and display across all types of devices.
3. It takes resources to design and develop a real-time web application, as most real-time data
requires expensive APIs from vendors. Finding sources of funding is often imperative to provide
real-time data analytics to extension audiences.
4. When considering developing web applications, strategize on how it can fit into a broader
extension program with supplemental resources.
5. It is important to note that when sharing these web applications, one must secure supporting
educational material that explains concepts and use of web applications. We provided
supplemental support in using the web application through different mediums, including
embedded articles and popups, concept-based short videos, webinars, presentations, and
workshops offering hands-on training. Providing various forms of support allows users to decide
on the level of support that they need and which mechanisms best suit their needs.
6. As documentation of impacts has become more critical in both extension and research settings,
web applications can help in reaching broader audiences who would not regularly attend an
extension workshop or read an applied research article. Moreover, web applications allow
multiple methods to track progress in learning and measure the adoption and use of information
for decision making. These features become invaluable in documenting impact, and in improving
future web applications. Specifically, R shiny applications allow the user to embed Google
Analytics (https://shiny.rstudio.com/articles/google-analytics.html), as well as create custom
programs to save and store user information.
4.1 Synergies Between University Teaching, Research, and Extension with
Extension-Based Web Applications
Web applications can empower stakeholders to engage in data analytics while avoiding having to teach
them coding or teach them how to build and test models. Further, web applications can be incorporated
into classroom settings to allow students to learn methods to develop the analysis used or to improve the
design of the web application for more exceptional user-friendliness. Students can provide a productive
beta testing environment for newly developed web applications. Ultimately, we aim to teach students in
the future how to build web applications on their own. We believe it would be beneficial to foster
competition between student web applications similar to poster competitions that can provide a forum
for developing web applications that best communicate results. Through the use of web applications,
agribusiness extension audiences can be kept abreast of the latest data analytic methods and analysis
that give them a competitive advantage.
About the Authors: Matthew S. Elliott is an Associate Professor in the Ness School of Management and Economics at South
Dakota State University (Corresponding Author: matthew.elliott@sdstate.edu). Lisa M. Elliott is an Associate Professor in the
Ness School of Management and Economics at South Dakota State University.
Acknowledgements: We gratefully acknowledge the support of this project by the South Dakota Agricultural Experiment
Station at South Dakota State University and by Hatch Project accession No. 1006890 and No. 1017800 from the USDA
National Institute of Food and Agriculture. Any opinions, findings, conclusions, or recommendations expressed in this
publication are those of the author(s) and do not necessarily reflect the view of the U.S. Department of Agriculture.
This material is based upon work that is supported by the National Institute of Food and Agriculture, U.S. Department of
Agriculture, Hatch project under 1017800 and No. 1006890.
Volume 2, September 2020
References
Anderson, M. 2019. “Mobile Technology and Home Broadband 2019,” December 31. Retrieved from
https://www.pewresearch.org/internet/2019/06/13/mobile-technology-and-home-broadband-2019/
Beeley, C. 2018. Hands-on Dashboard Development with Shiny: A Practical Guide to Building Effective Web Applications and
Dashboards. Birmingham UK: Packt Publishing.
Beeley, C., and S.R. Sukhdeve. 2018. Web Application Development with R Using Shiny. Birmingham UK: Packt Publishing.
Elliott, M., and L. Elliott. 2019. Real-time Tariff Impacts to Corn, Soybeans, and Wheat. http://agland.sdstate.edu/Tariff_web/
Elliott, M., and L. Elliott. 2020. Real-time Net Income Tool for Corn, Soybeans, and Wheat.
http://agland.sdstate.edu/Net_Income/
Elliott, M., and L. Elliott. 2020. Interactive Grain Report for Corn, Soybeans, and Wheat. http://agland.sdstate.edu/Grain/
Elliott, M., L. Elliott, D. Malo, and T. Wang. 2018. Ag Land HBU Study. http://agland.sdstate.edu/HBU/
Elliott, M., L. Elliott, D. Malo, and T. Wang. 2020. Ag Land Soil Tables. http://agland.sdstate.edu/Soil_Tables/
Granjon, D., V. Perrier, J. Coene, and I. Rudolf. 2019. shinyMobile: Mobile Ready “Shiny” Apps with Standalone Capabilities.
https://CRAN.R-project.org/package=shinyMobile
Lam, L. n.d. Flower Model. https://github.com/longhowlam/flowermodel
Lesmeister, C. 2019. Mastering Machine Learning with R Advanced Machine Learning Techniques for Building Smart Applications
with R 3.5. Birmingham UK: Packt Publishing.
Nijs, V. n.d. A Shiny App for Statistics and Machine Learning. https://shiny.rstudio.com/gallery/radiant.html
Pattani, A. 2016. “Silicon Valley Cultivates a Life on the American Family Farm.” CNBC.com.
Sievert, C. 2020. Interactive Web-Based Data Visualization with R, Plotly, and Shiny. Boca Raton FL: CRC Press.
Woodward, S. n.d. Pasture Potential Tool for Improving Dairy Farm Profitability and Environmental Impact.
https://shiny.rstudio.com/gallery/dairy-farms.html
©2020 APPLIED ECONOMICS TEACHING RESOURCES. Copyright is governed under Creative Commons BY-NC-SA 4.0
(https://creativecommons.org/licenses/by-nc-sa/4.0/). Articles may be reproduced or electronically distributed as long as attribution
to the authors, Applied Economics Teaching Resources and the Agricultural & Applied Economics Association is maintained.
Applied Economics Teaching Resources submissions and other information can be found at:
https://www.aaea.org/publications/applied-economics-teaching-resources.