Skip to main content

The Power and Versatility of R — More Than Just Statistics

1554 words·8 mins
William Cruz
Nuno Coração
Table of Contents

R is often perceived as a specialized tool solely for statisticians, but this perception vastly underestimates its capabilities. While R excels in statistical analysis and data manipulation, it’s also a powerful, general-purpose programming language with a rich ecosystem, expressive data models, and elegant visualization tools. It’s a dynamic environment that goes far beyond basic number crunching.

Beyond Statistics: A Comprehensive Ecosystem
#

At its core, R provides a robust foundation for statistical computing. Its extensive libraries (called “packages”) offer functions for virtually every statistical method imaginable, from simple descriptive statistics to advanced modeling techniques. R’s power, however, extends well beyond statistics to a wide range of tasks, including:

  • Data Cleansing and Transformation: R offers powerful tools for cleaning, transforming, and reshaping data. Packages like dplyr and tidyr provide an intuitive grammar of data manipulation, making it straightforward to prepare data for analysis.
  • Data Visualization: R is renowned for its exceptional data visualization capabilities. The ggplot2 package, based on the Grammar of Graphics, allows users to create stunning and informative visualizations with a high degree of customization. Beyond ggplot2, there are numerous other packages for interactive plots, maps, and specialized visualizations.
  • Interactive Web Applications (Shiny): The shiny package lets you build interactive web applications directly from R — ranging from simple dashboards to complex data exploration tools — without requiring extensive web development knowledge.
  • Machine Learning and Deep Learning: R has a thriving machine learning ecosystem, with packages like caret, mlr3, and keras (an interface to the popular Python deep learning library) providing access to a wide range of algorithms, including deep learning models. R’s powerful tools and libraries were instrumental in the optimization and refinement of the Apex algorithms.
  • Report Generation (R Markdown): R Markdown allows you to combine code, results, and narrative text in a single document, producing reproducible reports, presentations, and even entire books.
  • And much more: R’s capabilities extend to geospatial analysis, text mining, bioinformatics, econometrics, and many other specialized fields.

Community-Driven Development: The CRAN Repository
#

A key strength of R is its vibrant and active community. Developers worldwide contribute packages to the Comprehensive R Archive Network (CRAN), a central repository that makes it easy to install and use a vast collection of tools. This collaborative model ensures that R is constantly evolving, with new packages and features added regularly. Its open-source nature fosters innovation and keeps R at the forefront of data science.

This Website: A Testament to R’s Versatility
#

This entire website was built within the RStudio platform — an integrated development environment (IDE) specifically designed for R. While HTML, JavaScript, and CSS handle styling and front-end interactivity, the core structure and content management were handled using R. This demonstrates R’s remarkable flexibility and its ability to extend well beyond traditional statistical applications. The blogdown package (built on Hugo) makes it possible to create static websites directly from R Markdown documents.

Create a Website with R
#

These instructions will get you up and running with Hugo and Blowfish from a completely blank state. Most required dependencies can be installed using your platform’s package manager of choice. You can also follow the standard Hugo Quick Start guide to get up and running quickly.

Install Hugo
#

If you haven’t used Hugo before, you will need to install it onto your local machine. You can check whether it’s already installed by running the command hugo version.

Make sure you are using Hugo version 0.87.0 or later, as the theme takes advantage of some of the latest Hugo features.

Detailed installation instructions for your platform are available in the Hugo docs.

Blowfish Tools (recommended) #

There is a CLI tool available to help you get started with Blowfish. It will create a new Hugo project, install the theme, and set up the theme configuration files automatically. It’s still in beta, so please report any issues you find.

Install the CLI tool globally using npm (or another package manager):

npx blowfish-tools

or

npm i -g blowfish-tools

Then run the command blowfish-tools to start an interactive session that will guide you through the creation and configuration process:

blowfish-tools

You can also run blowfish-tools new to create a new Hugo project and install the theme in one step. Check the CLI help for more information:

blowfish-tools new mynewsite

Here’s a quick video showing how fast it is to get started with Blowfish using the CLI tool:

Install without CLI
#

Create a new site
#

Run the command hugo new site mywebsite to create a new Hugo site in a directory named mywebsite.

You can name the project directory whatever you like, but the instructions below will assume it’s named mywebsite. If you use a different name, substitute it accordingly.

Download the Blowfish theme
#

There are several different ways to install the Blowfish theme into your Hugo website. Listed from easiest to most complex to install and maintain:

If you’re unsure, choose the Git submodule method.

Install using git
#

This method is the quickest and easiest for keeping the theme up to date. Besides Hugo and Go, you’ll also need Git installed on your local machine.

Navigate into the directory for your Hugo website (created above), initialize a new git repository, and add Blowfish as a submodule:

cd mywebsite
git init
git submodule add -b main https://github.com/nunocoracao/blowfish.git themes/blowfish

Then continue to set up the theme configuration files.

Install using Hugo
#

With this method, Hugo manages your themes. Hugo uses Go to initialize and manage modules, so ensure go is installed before proceeding.

  1. Download and install Go. You can verify the installation with the command go version.

    Make sure you are using Go version 1.12 or later, as Hugo requires this for modules to work correctly.
  2. From your Hugo project directory (created above), initialize modules for your website:

    # If you're managing your project on GitHub
    hugo mod init github.com/<username>/<repo-name>
    
    # If you're managing your project locally
    hugo mod init my-project
    
  3. Add the theme to your configuration by creating a new file config/_default/module.toml with the following content:

    [[imports]]
    disable = false
    path = "github.com/nunocoracao/blowfish/v2"
    
  4. Start your server with hugo server and the theme will be downloaded automatically.

  5. Continue to set up the theme configuration files.

Install manually
#

  1. Download the latest release of the theme source code.

    Download from Github
  2. Extract the archive, rename the folder to blowfish, and move it to the themes/ directory inside your Hugo project’s root folder.

  3. Continue to set up the theme configuration files.

Set up theme configuration files
#

In the root folder of your website, delete the hugo.toml file that was generated by Hugo. Copy the *.toml config files from the theme into your config/_default/ folder. This ensures you have all the correct theme settings and makes it easy to customize the theme to your needs.

Note: Do not overwrite the module.toml file if one already exists in your project.

Depending on how you installed the theme, the config files will be in different locations:

  • Hugo Modules: In the Hugo cache directory, or download a copy from GitHub
  • Git submodule or Manual install: themes/blowfish/config/_default

Once you’ve copied the files, your config folder should look like this:

config/_default/
├─ hugo.toml
├─ languages.en.toml
├─ markup.toml
├─ menus.en.toml
├─ module.toml  # only if you installed using Hugo Modules
└─ params.toml
Important: If you did not use Hugo Modules to install Blowfish, you must add the line theme = "blowfish" to the top of your hugo.toml file.

Next steps
#

After installing Blowfish, build and serve your site following Mark Gingrass’s “Cradle to Grave R” YouTube series (Cradle to Grave R), specifically his tutorial “R Hugo Website. His comprehensive and clearly structured explanations are an excellent resource for this workflow. Once your site is running, you’re free to configure it to your needs.


Installing updates
#

From time to time, new releases are published that apply fixes and add new functionality to the theme. To take advantage of these changes, you will need to update the theme files on your website.

The process depends on the installation method you originally chose. Instructions for each are below.

Update using git
#

Git submodules can be updated with a single git command. Execute the following and the latest version of the theme will be pulled into your local repository:

git submodule update --remote --merge

Once the submodule has been updated, rebuild your site and verify everything works as expected.

Update using Hugo
#

Hugo makes updating modules straightforward. Navigate to your project directory and execute:

hugo mod get -u

Hugo will automatically update any required modules by inspecting your module.toml and go.mod files. If you encounter any issues, verify that these files are still configured correctly.

Rebuild your site and confirm everything works as expected.

Update manually
#

Updating Blowfish manually requires downloading the latest copy of the theme and replacing the old version in your project.

Any local customizations you have made to the theme files will be lost during this process.
  1. Download the latest release of the theme source code.

    Download from Github
  2. Extract the archive, rename the folder to blowfish, and move it to the themes/ directory inside your Hugo project’s root folder, overwriting the existing directory to replace all theme files.

  3. Rebuild your site and verify everything works as expected.

Author
William Cruz
CTO Apex Fintech