Installing R to use with Minitab Statistical Software

Verify that your R installation works with Minitab and run your first R script using Minitab.

Minitab Statistical Software integrates with R, a language and environment for statistical computing and graphing. To accomplish R integration, Minitab, LLC provides the mtbr package. With this custom R package, you can create tables, graphs, messages, and notes in R and display them in Minitab. R integration offers the flexibility of custom R code within Minitab's easy-to-use interface, and the results can be saved, stored, and shared in Minitab Project Files. After you install the mtbr package, you're ready to run R code from Minitab. If you have R code that you want to access routinely, you can customize Minitab's interface to make the analysis more accessible through custom buttons or menus.

For more information on Minitab's R package, including R code examples, go to R API Reference.

For information on R, consult the guidance available at www.r-project.org.

All the files referenced in this guide are available in this .ZIP file: r_guide_files.zip.

Requirements
  • Minitab Desktop 21.2. To check your version of Minitab, choose Help > About Minitab.
  • R 4.2.0 or newer
Note

If you are using any version of Minitab Desktop between 20.2 and 21.1.1 and an older version of R, contact Minitab Customer Support to obtain a compatible download for the mtbr package.

Step 1: Install R

Typically, the default installation of R works with Minitab. Follow the directions for your operating system at R's website.
Note

Install and run R before you attempt to integrate R with Minitab Statistical Software. For assistance with the installation of R, please consult with your organization's technical support department. Minitab Technical Support cannot assist with the installation of R.

Microsoft® Windows
  1. On R's website, under Downloads, click CRAN, then select an appropriate mirror. Typically, the default mirror of cloud.r-project.org works best.
  2. On the page, The Comprehensive R Archive Network, under Download and Install R, click Download R for Windows.
  3. On the page, R for Windows, click base.
  4. On the page, R-4.2.0 for Windows, click Download R-4.2.0 for Windows.
If R is not in your PATH, add R to your system environment variables. Otherwise, Minitab will not be able to find R. Usually, the path points to the location of the Rscript.exe file. For example, the path could be C:\R\R-4.2.0\bin\x64.
Note

If you are using R through an Anaconda environment, go to Additional instructions for Anaconda environments.

Step 2: Install mtbr

To use R with Minitab, install the mtbr package. The mtbr package gives you the capability to bring data from Minitab into R and to return R results to Minitab. Complete the following steps to install the latest version of the mtbr package.

  1. Go to www.minitab.com/support/downloads and download mtbr.
  2. Open an R terminal by running the "R {version}" application.
  3. Copy the following command to the R terminal and change the path to match the download location on your computer:
    install.packages("C:/Users/username/Downloads/mtbr_0.3.1.zip", repos = NULL)
  4. Press ENTER to run the command.

After R and the mtbr package are installed, you can use the RSCR command to run R from Minitab.

Step 3: Verify the installation with Minitab

Use the following steps to verify that Minitab can find R and mtbr.

Open Minitab

Run a test file

Use the following file to perform the steps in this section:
File Description
test.R A sample R script used throughout this guide. For this section, you run the script without arguments. When the script runs successfully, the result is the message "Minitab successfully located your R installation."
  1. Put test.R in Minitab's folder for R scripts. The default folder location depends on your operating system. For more information, go to Default folders for R files for Minitab.
  2. After you save the file, run the following command in the Command Line pane in Minitab:
    RSCR "test.R"
    Important

    If the Minitab Command Line is not visible, choose View > Command Line/History.

If R successfully works with Minitab, you will see the following output in Minitab:

R Script

These results are from external software.
Minitab successfully located your R installation.

Default folders for R files for Minitab

Typically, R integration with Minitab works best when the files that you use are in the default folder location for Minitab files. If you do not specify a file path when you run R from within Minitab, Minitab looks for your R files in the default folder.

Microsoft® Windows

The default location is the "My Documents" folder.

In the Microsoft® Windows operating system, if your R file is in the default folder and you receive the error "File not found:", check the default file location in your Minitab settings. To view or change the default file location in Minitab, choose File > Options > General > Default file location.

If the location is correct and you receive the error "Cannot open file:", examine the file path in Minitab's output for invalid or missing characters. If the file path contains invalid or missing characters, try moving or renaming the file.