Empowering budding corpus linguists with a custom shiny app
As corpus linguists, we often grapple with the question of how to empower students who may not have extensive coding skills to design tools that fit their research needs. With this in mind, I developed a modest yet very helpful Shiny app that simplifies running \chi^2 and Fisher’s exact tests for independence while offering access to the underlying code. This blog post explores how the app was built, its assets and limitations, and reflects on pedagogical goals.
Are you new to Shiny?
If you are new to Shiny, you may want to read this post, especially the section entitled “Shiny 101”. Shiny is a framework designed to enable researchers and data scientists to rapidly develop interactive web applications using the R or Python programming languages. Its intuitive structure makes it an ideal tool for creating user-friendly platforms to share and explore data, which is why it is very popular among data scientists. Shiny applications are particularly valued for their ability to visualize complex datasets and provide dynamic interfaces. Users are empowered to interact, which is why I think Shiny apps are a great addition to a professor’s toolbox.
The (humble) philosophy behind the (humble) app
Ready-made tools for corpus linguistics are user-friendly but often lack the flexibility needed to address specific requirements. Excellent tools such as AntConc (a concordance program for analyzing text, available at AntConc) and #LancsBox (a tool for corpus analysis and visualization, found at #LancsBox), which I frequently use in class with linguistics beginners, come to mind. However, a common limitation is their inability to help students select appropriate statistical methods based on the characteristics of the data (e.g., using Fisher’s exact test for small samples). This year, I decided to develop an app for my students at Université Bordeaux Montaigne to address this limitation. The app is not intended to replace existing tools. Rather, it is designed to complement them.
In a nutshell, the app allows students to upload contingency tables in various formats, automatically selects and executes either \chi^2 or Fisher’s exact test based on expected frequencies, generates visualizations such as association plots and mosaic plots to aid interpretation, and provides fully commented code to enhance transparency and support learning.

Fisher’s exact test and the \chi^2 test of independence are both used to assess whether two categorical variables are independent. They differ in their assumptions and ideal use cases. Fisher’s exact test is particularly well-suited for small sample sizes or situations where the expected cell frequencies in a contingency table are very low (less than 5). Unlike tests that rely on approximations, Fisher’s exact test calculates the exact probability of observing the data under the null hypothesis. This makes it a good choice for sparse data. The \chi^2 test of independence, on the other hand, is ideal for larger datasets where all expected cell frequencies are sufficiently high (greater than 5). This test works by comparing the observed frequencies in the data to the expected frequencies under the null hypothesis. It is parametric as it uses an approximation based on the \chi^2 distribution. While it is faster and computationally simpler for large tables, the \chi^2 test is less accurate for small sample sizes (its reliance on approximations can lead to errors).
This app invites both critical thinking and ownership. By making the decision-making process explicit (e.g., why Fisher’s exact test might be used instead of \chi^2), the app initiates students to matching statistical methods to data characteristics. Students are also strongly encouraged to adapt the app for their specific needs, especially if they want to pursue a curriculum in linguistics.
The source code are available on my GitHub repository. Admittedly, I am not the best at coming up with creative names for my scripts, so the app is simply called chisq-fisher-viz. A good idea would be to launch it before continuing to read. Since I’m on a free plan, shinyapps.io limits app usage on their servers to 25 hours. For this reason, I am not sharing the hosted link. The good news is that you can run it locally or download, publish, and run the script for free at https://www.shinyapps.io/.
How the app works
As any other Shiny app, this one relies on a simple user interface (UI) and robust server-side logic. The students can upload tables in .xlsx, .csv, or .txt format, and the app validates the data to ensure that no rows or columns are empty.
Here is what the tables can look like.


The Shiny app selects the appropriate statistical test by applying \chi^2 if any expected cell frequency is greater than 5, as in Fig. 1, or Fisher’s exact test if any expected cell frequency is below 5, as in Fig. 2.
With the first sample input file, the \chi^2 test of independence is applied (Fig. 3).

vcd package for R)The Shiny app displays a Cohen-Friendly association plot, along with the results in clear tables with observed, expected frequencies, and residuals, as well as a p-value.

With the second sample input file, Fisher’s exact test of independence is applied (Fig. 5). This time, a mosaic plot is displayed and the table of residuals is not proposed (Fig. 6).


Importantly, the Shiny app explains the results to help students decide whether to reject or fail to reject the null hypothesis. This presupposes that you have explained hypothesis testing beforehand, but that is quite manageable. FYI, I cover hypothesis testing in Chapter 8 of my book Corpus Linguistics and Statistics with R.
Assets
One key asset of such an app is its dual focus: it is meant to be both easy to use, and it provides a learning opportunity. Indeed, students can run tests without learning R, and the fully commented R code is accessible via GitHub. Students can therefore understand how the app works under the hood. They can also adapt or extend it for their own research, once they are more proficient in R programming.
Limitations and next steps
This app represents a first step forward, but it is not without limitations. One concern is the association of residuals with Fisher’s exact test, which can be misleading. While residuals are meaningful for \chi^2, their interpretation alongside Fisher’s test is less straightforward.
Visualization choices also present challenges. Mosaic plots, for instance, are visually appealing but are not strictly tied to Fisher’s exact test. Their inclusion in the app might lead students to assume these are the “natural” extensions of the test. Although mosaic plots are sometimes used with Fisher’s test, other visualizations, such as heatmaps, might be equally appropriate. Future updates could refine these visualizations to better match their intended statistical contexts.
Additionally, the app simplifies complex statistical assumptions and relationships, which risks giving users a false sense of mastery. Adding warnings about the limitations of specific tests and linking to resources on statistical theory will help address this issue in future versions.
Scalability is another consideration. While the app works well for small to medium-sized datasets, handling larger datasets or more complex statistical tests may require optimization or additional features in the future.
Concluding thoughts
This Shiny app is part of a broader effort to give linguistics students access to practical, user-friendly tools, especially when their curriculum does not include training in computational or quantitative methods, as is often the case in the humanities.
The app aims to strike a balance between being easy to use and supporting solid learning outcomes. It is designed to help students explore statistics without getting overwhelmed by technical details. I believe our role as educators is not just to teach specific tools but to spark curiosity, encourage adaptability, and nurture critical thinking.
If you try the app or use it in your classes, I would love to hear how it works for you! Feedback, suggestions, and contributions are always welcome.
The text only may be used under licence Creative Commons Attribution Non Commercial 4.0 International. All other elements (illustrations, imported files) are “All rights reserved”, unless otherwise stated.
OpenEdition suggests that you cite this post as follows:
Guillaume Desagulier (December 8, 2024). Empowering budding corpus linguists with a custom shiny app. Around the word. Retrieved May 21, 2026 from https://doi.org/10.58079/12v9b


orcid.org/0000-0003-4895-0788