My first Shiny App: control charts

[This article was first published on The Beginner Programmer, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

After having carefully followed the online official Shiny tutorial, I decided to make a quick try at making my very first Shiny App. I should say that I found myself very well with the explanation given and Shiny was definitely one of the libraries that took the less time for me to start using it. Of course I’m still not a master of Shiny by no means, but I feel more confident on how to use it and on what can be done with it.

Image 1

I’m working on an R project related to control charts and I was hinted to get to know Shiny, since it is very likely that the project will involve an interactive interface and Shiny fits the bill perfectly for this assignment. For this reason I took an afternoon for getting familiar with Shiny and build this App. Enough talk, let’s get to the App.

App description

The App is designed with one objective only: let me learn Shiny :D. I think this is quite obvious to the expert developer, however, the main idea is to allow the user to upload a .csv file of ungrouped observations, select the control chart to plot, group size, variable to plot, and then display the control chart and the results of the calculation as a data table.

Input data structure

The input file must be a .csv. So far I have not allowed other formats. The .csv can contain as many variables as you like, there is no limit, but bear in mind that Shiny (the free version at least) limits the size of files that can be uploaded to 5 MB. The file should have no row names, however, in case row names are present, do not reserve a free spot (“ ”) in the columns name row at the beginning of the file and everything should work fine. The data should be a series of consecutive measurements at a given constant frequency. For instance, if you took 2 measures of a certain variable y each day for 3 days, your data should be in the following format:

2, 1003

Of course, the day_id variable is not necessary. In this case the group size would be 2. For more information and an example of the allowed .csv format please check the readme.

Available charts

Only charts for quantitative variables are available. So far, the xbar-s and s charts are the only two supported. You can choose how many $\sigma$ you would like your control limits to be wide, 3 is the default but you can choose a higher or lower margin. The parameters of the control chart are showed in a table below the graph for further inspection.

Where to find the App

The App is available here. By default, the mtcars dataset is used, although it is not the exact fit it is needed just for show until you upload your data.

The application seems to run smoothly and overall I’m quite happy with how it turned out. This was just a test application for myself, so I did not take that much care of the graphical side of the application. Any comment is welcomed, thank you.

To leave a comment for the author, please follow the link and comment on their blog: The Beginner Programmer. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)