Skip to main content

University Library, University of Illinois at Urbana-Champaign

Introduction to R: Video Tutorials on Using R

A brief tutorial on the R programming language.

Introduction to R, a video series by Google on YouTube

Listed below are 21 short videos that Google released on its Google Developers YouTube channel to provide a working overview of The R Project for Statistical Computing.  Each video is focused on a task or concept in R and is less than seven minutes. 

1) R 1.1 - Initial Setup and Navigation

This video provides strategies that will make beginning R users more efficient: writing code using a "script" and navigating through directories within R.

2) R 1.2 - Calculations and Variables

Get acquainted with performing basic computations in R, creating R objects (sometimes called "variables"), and seeing and running earlier commands that were run in the console.

3) R 1.3 - Create and Work With Vectors

Learn how to create a vector in R using the c() function and the colon-notation (e.g. 1:5), find the length of a vector using the length() function, and subset vectors with bracket-notation and the head() and tail() functions.

4) R 1.4 - Character and Boolean Vectors

So far we've seen objects that use numbers, but R is also built to handle more types of objects. Here we explore vectors that contain strings or Boolean values (TRUE / FALSE).

5) R 1.5 - Vector Arithmetic

This video demystifies the different ways R performs vector arithmetic (e.g. addition and multiplication), covering topics including element-wise arithmetic, vector recycling, and how some functions are automatically applied across the elements in a vector. The seq() function is also introduced.

6) R 1.6 - Building and Subsetting Matrices

Learn how to create a matrix with dimensions of your choosing, how recycle a vector when creating a matrix, and how to query specific characteristics of the vector using functions such as dim(), head(), and tail(). Details and potential pitfalls for subsetting a matrix using the bracket-notation are also covered.

7) R 1.7 - Section 1 Review and Help Files

A quick review of the topics covered in the Section 1 videos: vectors, matrices, subsetting, and a few standard functions. Also learn how to access help files in R.

8) R 2.1 - Loading Data and Working With Data Frames

Get a refresher on navigating directories on your computer in R, and learn to load a CSV (comma-separated values) data set in the form of a "data frame" using the read.csv() function, which is a special type of data matrix. This video also introduces factor variables and explores the data in a data frame using the dim(), head(), length(), names(), and subset() functions

9) R 2.2 - Loading Data, Object Summaries, and Dates

Learn how to load data in the form of a tab-delimited text file using the read.delim(), how to get a high-level overview of an R object using the str() and summary() functions, and get a crash-course into working with dates in R with an example highlighting why this skill is so useful.

10) R 2.3 - if() Statements, Logical Operators, and the which() Function

If-else statements are a key component to any programming language. This video introduces how to effectively use these statements in R and also clarifies some nuances of logical operators in R. Two related functions are also introduced: ifelse() as a shortcut that can be used to create faster and more readable code, and the which() function that retrieves the positions in a Boolean vector that are TRUE.

11) R 2.4 - for() Loops and Handling Missing Observations

This video discusses for() loops, which are a structure that can be used to execute a set of code repeatedly. Also covered in this video are the min(), max(), and append() functions, as well as how to identify and omit missing values.

12) R 2.5 - Lists

Learn how to create and use lists in R, which are dynamic, flexible R objects that can hold and organize other R objects.

13) R 3.1 - Managing the Workspace and Variable Casting

View all the objects in the workspace using ls(), remove objects using rm(), cast a variable as a different type using an as.[type]() function, and use lists or data frames to organize data or results.

14) R 3.2 - The apply() Family of Functions

When data are organized in a matrix or data frame, the apply() function can be used to calculate summaries (or apply a more complex function) across either the rows or columns of the data object. Or if summaries for each group (level) of one or more variables are desired, use the tapply() or by() function.

15) R 3.3 - Access or Create Columns in Data Frames, or Simplify a Data Frame using aggregate()

The with() function makes it easy to access many variables (columns) in a data frame for one-off calculations, the within() function can be used to create new columns that are merged with the original data frame, and aggregate() is useful for aggregating variables in a data frame across groupings based on one or more variables.

16) R 4.1 - Basic Structure of a Function

This video introduces the basic structure of a function, covering the declaration of the function, using an argument, and returning a result.

17) R 4.2 - Returning a List and Providing Default Arguments

Become more proficient in writing functions by learning the standard way to return more complex results from functions using a list, and learn how to specify a default value for an argument.

18) R 4.3 - Add a Warning or Stop the Function Execution

The most helpful functions return clear warnings and errors when something is wrong. This video introduces the warning() and stop() functions, which can be used within a function to report a warning to the user or stop the function's execution.

19) R 4.4 - Passing Additional Arguments Using an Ellipsis

Sometimes it is useful to be able to pass any extra arguments to another function. For example, if a new plotting function is created that makes use of the function called plot(), it would be useful to be able to be able to specify additional details to plot() automatically. This is possible using an ellipsis, "...".

20) R 4.5 - Make a Returned Result Invisible and Build Recursive Functions

Use the invisible() function in place of return() in a function to prevent the output from printing to the user's screen but still allow the result to be stored into an R object. Additionally, when building a recursive function, use the Recall() function.

21) R 4.6 - Custom Functions With apply()

In the last section of videos, the apply() function was introduced. A prebuilt function is often used in this function, but it is also common to write a new function within apply() or to apply a custom function.