| University Libraries

See Updates and FAQs for the latest library services updates. Subject Librarians are available for online appointments, and Virtual Reference has extended hours.

Resources to learn and use the Open Source Statistical software R (R-Project)

- Start Here
- General Tutorials
- Statistical Analysis
- Data Management
- Graphics
- Data Science
- Good Practices
- Get Help

Research Consultant

The R Project for Statistical Computing is a **free**, open source **statistical computing language** that is popular among researchers in many fields.

The learning curve for true understanding is steep, but specific tasks (e.g., importing files from other statistical software) are often quite easy because of packages that can be created by anybody. R undergoes **rapid development** and improvement. Tutorials even a year old may be **out of date**.

Note that **RStudio **is currently in the process of changing names to **Posit.** Various tutorials may reference one or the other, but both are acceptable at this time.

- R for
**Data Management** - R for
**Statistical Analysis** - R for
**Data Visualization**

See the slides from our Getting Started with R (pdf) workshop for an overview and recommendations.

Make sure you know the basic concepts and terminology that are often **not taught **in classes. These are short overviews of particular topics that you need to. Check the comprehensive resources for more information.

Functions in R are the same as those in any programing language, in Algebra, or in Excel.

Look for a word or letter followed by parentheses:

. The *word***()***word *is the name of the function.

Videos: Functions (~1min) and Arguments (~2min, RStudio) or Using Functions (~4min, Intro 2R)

Text: Call a function on a number or Run a Function (Posit Recipies) or Functions (R4Epis)

**Packages **are the code for groups of functions. You must download them to your computer and load them into R to use them.

Packages can be specified with ** ::** , as in

Videos: Installing Packages (~2min, RStudio) or Installing R Packages (~4min, Intro 2R)

The **Pipe **( `|>`

or `%>%`

) is a way to "chain" functions to avoid nesting parentheses and improve workflow.

Video: Pipe (~5min) (LinkedIn Learning - Log in with Mason)

Some languages (and tutorials) call these "variables", but R's term is "objects" to avoid confusion with data variables.(columns in tabular data). It is a name (word) that represents some data, whether a single value, a group of values, or an entire dataset.

Objects are created with `<-`

(the "assignment operator") as in *object ***<-** *contents*

Videos: Objects in R (~3min, Intro 2R)

Text: Objects (R4Eips) - Includes the topics below.

Objects contain different types or classes of data and functions may act differently for different types.

**Structures **include: vector, list, data.frame, and matrix

**Types **include: chr, num, dbl, int, logi, and fct

- Videos:
- Data Types and Structures (~10 min, LinkedIn Learning - Log in with Mason)
- Data Formats ~15 min, DataLab CC

**Parts of objects** are referred to using `$`

, `[]`

or `[[`

`]]`

In many cases*, **object *is a **data frame**, and *part *is a **variable** within (both referred to by their names).

But, an R list object can contain any data type, including other lists or data frames.

*object***$***part →*the part*object***["***part***"]***→*an object containing only the part*object***[["***part***"]]***→*the part

**RStudio **= **Posit **(the company is changing names)

Video walk-through specifically for Windows or Mac (OpenIntro)

- NOTE: The RStudio / Posit website undergoes frequent changes so the process of downloading RStudio will be slightly different. But, the links/buttons use the same names (and have blue backgrounds to stand out).
- See also the interactive Setup Tutorial
- Install R
- Install RStudio
- Install Packages

- R with RStudio: Getting Started (~1.5 hrs): Shows all the basics of starting and organizing a process, opening a data file and doing basic data management and visualization. Markdown document with the code
- An Introduction to R by University of Aberdeen - Focused on Ecology and Biostatistics
- R Basics from The Epidemiologist R Handbook: Describes all the fundamentals and much more.
- Learn R in 39 minutes (39 min, Equitable Equations) - Good overview of getting started and key functions in R, but goes quickly and may use terminology some are unfamiliar with.
- R: An Introduction Playlist / one video (~2.2 hrs) from Barton Paulson / datalab.cc - Goes slowly for beginners, and talks about his favorite packages such as rio, pacman, and tidyverse. Covers visualization, data management, and regression.

- R for Data Science by Hadley Wickham; Mine Çetinkaya-Rundel; Garrett Grolemund Use R to turn data into insight, knowledge, and understanding. With this practical book, aspiring data scientists will learn how to do data science with R and RStudio, along with the tidyverseâ??a collection of R packages designed to work together to make data science fast, fluent, and fun. Even if you have no programming experience, this updated edition will have you doing data science quickly. You'll learn how to import, transform, and visualize your data and communicate the results. And you'll get a complete, big-picture understanding of the data science cycle and the basic tools you need to manage the details. Updated for the latest tidyverse features and best practices, new chapters show you how to get data from spreadsheets, databases, and websites. Exercises help you practice what you've learned along the way. You'll understand how to: Visualize: Create plots for data exploration and communication of results Transform: Discover variable types and the tools to work with them Import: Get data into R and in a form convenient for analysis Program: Learn R tools for solving data problems with greater clarity and ease Communicate: Integrate prose, code, and results with QuartoCall Number: Available Online through the authorISBN: 9781492097402Publication Date: 2023-07-18

This book is one of the best resources and good to either read or refer to. However, non-programmers who want help with the very first steps should look elsewhere.

- Using RStudio (~8min) (LinkedIn Learning - Log in with Mason)
- Notebooks
- Note:
**R Markdown**documents look and work the same as Quarto documents. But, Quarto provides more features, including a visual editor and multi-language support. If your instructor asks you to use R Markdown, the Quarto video will still be useful. Or, you might politely ask your instructor if you can submit a Quarto document instead, as they may not know about this new feature. - Quarto Visual Editor [Part 1] (~10min, Andy Field)

- Note:

- Why The R Programming Language Is Good For Business (FastCompany)
- Choosing R or Python for Data Analysis (DataCamp) - From 2015, but still useful
- Where should I start - R or Python? (SAGE campus)
- Python can be better for general tasks, plus data collection and machine learning
- R can be better for analysis, like network analysis and statistics, and visualization

- If you know other
**programing**languages,**Python**will likely be easier to start with. - If you
*instead*are familiar with**statistical**software,**R**will likely be easier to start with. - If you are just starting out,
- Pick
**R**If you will mostly work with**data tables**and be in an**academic**context - Pick
**Python**if you will work with**text**or**websites**and/or be in a**business**context

- Pick

Many people will ultimately learn both. But, they are similar enough that you do not want to learn them at the same time--it can get confusing to switch back and forth. Knowing either one will help you learn the other. So, just pick one and get started!

If you already know another statistical software or programming language, you might try these first.

- R language for programmers by John D. Cook
- MATLAB, NumPY, Julia and R Side-by-side reference sheet - Hyperpolyglot
- Python → R: Introduction to R
- MATLAB → R: MATLAB® / R Reference, by David Hiebeler
- Stata → R: R for Stata Users (Uses R-Commander. Useful glossary/comparison of codes , p. 497)
- Data manipulation in R for Stata users - (Quick reference guide)
- Getting Started in R/Stata pdf (side-by-side tutorial)

- Excel → R:
- R For Excel Users Tutorials & Book by John Taveras
- Video: R for Excel Users LinkedIn Learning

- Last Updated: Jul 28, 2024 9:52 AM
- URL: https://infoguides.gmu.edu/learn_r
- Print Page

**Ask a Librarian | Hours & Directions | Mason Libraries Home**

Copyright © George Mason University