Journal of Behavioral Data Science, 2024, 4 (2), 1–6.
DOI: https://doi.org/10.35566/jbds/rodrigues

greekLetters: Routines for Writing Greek Letters and Mathematical Symbols on the RStudio and RGui

Kévin Allan Sales Rodrigues\(^{[0000-0003-4925-5883]}\)
University of São Paulo, São Paulo, Brazil
kevin@alumni.usp.br
Abstract. This is a brief description of the greekLetters R package. In short, greekLetters is a package for displaying Greek letters and various mathematical symbols in RStudio and RGui environments.

Keywords: R · Statistical notation · Mathematical symbols · Greek letters

1 Introduction

The R (R Core Team2024) ecosystem lacks a dedicated, streamlined package for incorporating Greek letters and mathematical symbols into text outputs seamlessly. The greekLetters package (Rodrigues2023) addresses this need, offering a comprehensive toolkit for displaying Greek letters and various mathematical symbols in RStudio (Posit team2024) and RGui environments.

Designed for ease of use, the package facilitates the inclusion of Greek letters and math equations in RGui and RStudio, enhancing the clarity and presentation of statistical notation. The package ensures compatibility across operating systems by encoding characters in UTF-8. Additionally, it supports the creation of summary functions that incorporate the functional form of fitted models with Greek letters, bridging the gap between statistical theory and practice. The package’s simplicity and accessibility make it an essential tool for enhancing the presentation and understanding of statistical concepts in R.

The article is organized as follows. Section 2 provides the rationale for the existence of the package. Section 3 explains the syntax for using Greek letter symbols and mathematical symbols, Section 4 presents some examples of how to use the greekLetters package. Section 5 details where the package is available and how to install it. The final section discusses the package documentation.

2 Statement of need

Incorporating Greek letters and mathematical symbols in R outputs is essential for clear and accurate statistical notation, particularly in educational and professional settings. However, R lacks a package that fills this gap. Existing solutions are limited in scope and functionality, especially in environments like RGui where Unicode support is partial.

The greekLetters package (Rodrigues2023) fills this gap by providing functions to display Greek letters and mathematical symbols consistently across RStudio and RGui. This capability is crucial for creating clear and professional statistical outputs, enhancing the communication and understanding of statistical models and results.

Thus, the greekLetters package will be useful as a support package for the development of other packages, serving to create summaries with equations and mathematical symbols, as well as assisting in the communication of other R outputs. An example of a package that depends on greekLetters is diagL1 (Rodrigues & Elian2024). It is expected that in the coming years, greekLetters will be used in more packages.

The next section deals with the syntax for using Greek letters and mathematical symbols.

3 Syntax

The syntax for using the symbols is simple, just use the greeks() function as shown in the following command.

# Basic syntax 
greeks("math_symbol_or_Greek_letter_name")

To write equations, simply concatenate the symbols, which can be done using the paste() and paste0() functions. The paste() function uses a space, “ ”, as the default separator, but it allows other symbols to be defined as separators. On the other hand, the paste0() function does not insert any separators between the concatenated strings.

Figure 1 contains the output of the print_greeks() function, which lists the symbols and their respective names, allowing the greeks() function to generate these symbols.

PIC

Figure 1: Output of print_greeks() containing symbols names for greeks() function.

The next section will present examples illustrating the utility of the package.

4 Examples

Here are some straightforward examples showcasing greekLetters utility. To denote the approximation of \(\pi \), you can use:

# pi constant 
paste(greeks("pi"), greeks("almostEqual"), "3.14")

The linear regression equation, in matrix form, can be elegantly displayed using Greek letters for the coefficients and error term:

# Linear regression 
paste("y", " = X", greeks("beta"), " + ", 
greeks("epsilon"), sep ="")

The expected value of a random variable X can be represented as:

# Expected value 
paste("E[X] = ", greeks("integral"), "xf(x)dx", 
 sep = "")

The notation for testing a statistical hypothesis can be shown as:

# Testing statistical hypothesis 
paste(greeks("H_0"), ":", greeks("mu"), "= 0") 
paste("versus", greeks("H_1"), ":", 
greeks("mu"), greeks("notEqual"), "0" )

Figure 2 contains the outputs of the presented commands.

PIC

Figure 2: R console outputs with mathematical equations and Greek letters.

By using the greekLetters package, these examples demonstrate how to effectively incorporate Greek letters and mathematical symbols into R outputs, enhancing the clarity of R statistical outputs.

The next section will explain how to install the package and describe its license, detailing what can be done with it.

5 Package availability and license

The greekLetters package is hosted on the official CRAN (The Comprehensive R Archive Network) repository, ensuring its reliability and easy access for all R users. The package can be found and downloaded via the following link: https://cran.r-project.org/package=greekLetters. Being available on CRAN ensures that the package has undergone rigorous quality and compliance checks, guaranteeing its compatibility with different versions of R and various operating systems. Additionally, its presence on CRAN facilitates the installation and updating of the package directly through R using simple commands like:

install.packages("greekLetters")

Additionally, the greekLetters package is licensed under the GNU General Public License version 3 (GPLv3), which provides several freedoms and responsibilities. This license allows anyone to use the software for any purpose, whether personal, educational, or commercial, and requires the source code to be available, enabling users to study, modify, and adapt the software to their needs.

Users have the right to modify the greekLetters code and distribute both the original code and modified versions, as long as they do so under the same terms of the GPLv3. This includes providing or making the source code available with any distribution of the software, ensuring continuous transparency and openness. When distributing greekLetters, it is necessary to keep the copyright notices and the GPLv3 license intact, ensuring that all recipients are aware of their rights and responsibilities.

The GPLv3 also requires license compatibility when combining greekLetters with other software and includes provisions that address patents, protecting users against claims that could restrict their freedoms. Adopting this license promotes collaboration in the free software community and ensures that the package remains free and open for future developers and users, which is crucial for a support package like greekLetters that can be widely integrated and used by other packages, such as diagL1 (Rodrigues & Elian2024), and many others in the future.

This accessibility and ongoing support make greekLetters a valuable tool for anyone needing to incorporate Greek letters and mathematical symbols into their R outputs. The next and final section will provide some comments on the software documentation.

6 Manual and documentation

Extensive documentation accompanies the package, featuring detailed descriptions and examples for each function. This thorough documentation aids users in effectively utilizing the package’s capabilities, ensuring they can integrate Greek letters and mathematical symbols into their R outputs with ease. The package’s comprehensive testing and documentation guarantee a reliable and user-friendly experience.

The manual is available on the package’s page and can be accessed without any registration. Additionally, the documentation for each function can be accessed within R using the help() command.

Acknowledgments

The author gratefully acknowledges CNPq (Brazilian National Council for Scientific and Technological Development) for the financial support.

References

   Posit team. (2024). Rstudio: Integrated development environment for r [Computer software manual]. Boston, MA. Retrieved from http://www.posit.co/

   R Core Team. (2024). R: A language and environment for statistical computing [Computer software manual]. Vienna, Austria. Retrieved from http://www.R-project.org

   Rodrigues, K. A. S. (2023). greekLetters: routines for writing greek letters and mathematical symbols on the RStudio and RGui [Computer software manual]. Retrieved from https://CRAN.R-project.org/package=greekLetters (R package version 1.0.2) doi: https://doi.org/10.32614/CRAN.package.greekLetters

   Rodrigues, K. A. S., & Elian, S. N. (2024). diagL1: Routines for fit, inference and diagnostics in linear L1 and LAD models [Computer software manual]. Retrieved from https://CRAN.R-project.org/package=diagL1 (R package version 1.0.0) doi: https://doi.org/10.32614/CRAN.package.diagL1