# R Programming Language (Analysis Software for Statistics & Data Science)

R is a programming language and software that is becoming increasingly popular in the disciplines of statistics and data science.

R is a dialect of the S programming language and was developed by Ross Ihaka and Robert Gentleman in the year 1995. A stable beta version was released in the year 2000.

The R software is completely free and gets developed collaboratively by its community (open source software) – every R user can publish new add-on packages.

The open source ideology of R programming reflects a huge contrast compared to most traditional programming environments (e.g. SAS, SPSS, Stata etc.), where the software development is in the hands of a payed development team.

## All R Tutorials on statisticsglobe.com

In the following, you can find a list of R tutorials on statisticsglobe.com. In the tutorials, I’m explaining statistical concepts and provide reproducible example codes in R.

### Add Common Legend to Combined ggplot2 Plots in R (Example)

Add Common Legend to Combined ggplot2 Plots in R (Example)   In this article, I'll illustrate how to create a shared legend for multiple ggplot2 graphics in the R programming language . Table of contents: Example Data Example:...

Add Leading Zeros in R (Example)   This article shows how to add leading zeros to a vector in the R programming language . Below, you can find a reproducible R code. The R code is structured as follows: Creation of Example Data ...

### Adjust Space Between ggplot2 Axis Labels and Plot Area in R (2 Examples)

Adjust Space Between ggplot2 Axis Labels and Plot Area in R (2 Examples)   In this R programming tutorial , I'll explain how to adjust the space between the ggplot2 axis labels and the plot area . The article contains the following content: Creation...

### all_equal Function of dplyr R Package (2 Examples)

all_equal Function of dplyr R Package (2 Examples)   This article explains how to use the all_equal function of the dplyr package in the R programming language . Table of contents: Creating Exemplifying Data Example 1: Compare...

### Append Value to Vector in R (4 Examples)

Append Value to Vector in R (4 Examples)   In this tutorial you'll learn how to append a new value to a vector in the R programming language . The table of content is structured as follows: Creating Example Data Example 1: Append...

### apropos & find Functions in R (2 Examples)

apropos & find Functions in R (2 Examples)   This tutorial explains how to find objects by (partial) names in the R programming language . The tutorial will be based on the functions apropos() and find(). Let's have a look at the basic...

### arrange Function of dplyr R Package (2 Examples)

arrange Function of dplyr R Package (2 Examples)   In this R article you'll learn how to order data sets with the arrange function of the dplyr package . Table of contents: Example Data Example 1: Arrange Data By One Variable...

### as.tbl & is.tbl R Functions of dplyr Package (2 Examples)

as.tbl & is.tbl R Functions of dplyr Package (2 Examples)   In this article you'll learn how to create and check tibbles with the as.tbl and is.tbl functions of the dplyr package in R . The content looks as follows: Creation of Example...

### asp in R Plot (2 Example Codes) | Set Aspect Ratio of Scatterplot & Barplot

asp in R Plot (2 Example Codes) | Set Aspect Ratio of Scatterplot & Barplot   In this R tutorial, I'm going to show you how to use the asp option to set the aspect ratio of a plot, i.e. the proportional relationship between width and height...

### Assign Fixed Colors to Categorical Variable in ggplot2 Plot in R (Example)

Assign Fixed Colors to Categorical Variable in ggplot2 Plot in R (Example)   This page shows how to assign pre-defined colors to qualitative variables in a ggplot2 plot in R programming . Table of contents: Creating Example Data ...

### attach & detach Functions in R | 2 Examples: Data Frame & Package

attach & detach Functions in R | 2 Examples: Data Frame & Package   In this article I will show you how to handle data.frames with the attach and detach functions in R . Let’s start with the basic R syntax and the definition of the two f...

### attr, attributes & structure Functions in R | 4 Examples (get, remove & set)

attr, attributes & structure Functions in R | 4 Examples (get, remove & set)   In the following R tutorial, I’m going to show you three functions, with which you can get or set the attributes of your data: attributes function (Examples 1...

### Barplot in R (8 Examples) | How to Create Barchart & Bargraph in RStudio

Barplot in R (8 Examples) | How to Create Barchart & Bargraph in RStudio   In this post you'll learn how to draw a barplot (or barchart, bargraph) in R programming . The page consists of eight examples for the creation of barplots. More...

### Bernoulli Distribution in R (4 Examples) | dbern, pbern, qbern & rbern Functions

Bernoulli Distribution in R (4 Examples) | dbern, pbern, qbern & rbern Functions   In this R tutorial you'll learn how to apply the Bernoulli distribution functions . Table of contents: Example 1: Bernoulli Probability Density Function...

### Beta Distribution in R (4 Examples) | dbeta, pbeta, qbeta & rbeta Functions

Beta Distribution in R (4 Examples) | dbeta, pbeta, qbeta & rbeta Functions   This article shows how to use the beta functions in R programming . The content of the page looks as follows: Example 1: Beta Density in R (dbeta Function)...

### between Function of dplyr R Package (2 Examples)

between Function of dplyr R Package (2 Examples)   In this tutorial, I'll illustrate how to test whether a numeric value falls into a specified range with the between function of the dplyr package in R . Table of contents: Example...

### bind_rows & bind_cols R Functions of dplyr Package (2 Examples)

bind_rows & bind_cols R Functions of dplyr Package (2 Examples)   In this article, I'll explain how to merge rows and columns with the bind_rows and bind_cols functions of the dplyr package in R . The table of content is structured like...

### Binomial Distribution in R (4 Examples) | dbinom, pbinom, qbinom & rbinom Functions

Binomial Distribution in R (4 Examples) | dbinom, pbinom, qbinom & rbinom Functions   In this tutorial you'll learn how to apply the binom functions in R programming . The tutorial is structured as follows: Example 1: Binomial Density...

### Boxplot in R (9 Examples) | Create a Box-and-Whisker Plot in RStudio

Boxplot in R (9 Examples) | Create a Box-and-Whisker Plot in RStudio   In this tutorial, I'll show how to draw boxplots in R . The tutorial will contain these topics: Example 1: Basic Box-and-Whisker Plot in R Example 2: Multiple...

### break & next Functions in R for-loop (2 Examples)

break & next Functions in R for-loop (2 Examples)   This tutorial shows how to use the break and next commands within a for-loop in R . Without further ado, let's move directly to the examples!   Create Basic for-loop in R (without...

### Cauchy Density in R (4 Examples) | dcauchy, pcauchy, qcauchy & rcauchy Functions

Cauchy Density in R (4 Examples) | dcauchy, pcauchy, qcauchy & rcauchy Functions   In this R tutorial you'll learn how to apply the cauchy functions . The page contains four examples for the application of dcauchy, pcauchy, qcauchy, and...

### cbind R Command | 3 Example Codes (Data Frame, Vector & Multiple Columns)

cbind R Command | 3 Example Codes (Data Frame, Vector & Multiple Columns)   Basic R Syntax: cbind(my_data, new_column)   The name of the cbind R function stands for column-bind . The cbind function is used to combine vectors,...

### Change Font Size of ggplot2 Plot in R (5 Examples) | Axis Text, Main Title & Legend

Change Font Size of ggplot2 Plot in R (5 Examples) | Axis Text, Main Title & Legend   In this article, I'll explain how to increase and decrease the text font sizes of ggplot2 plots in R . The tutorial consists of these content blocks: Example...

### Change Legend Title in ggplot2 (2 Example Codes) | Modify Text of ggplot Legends

Change Legend Title in ggplot2 (2 Example Codes) | Modify Text of ggplot Legends   This article explains how to change the text of a ggplot2 legend in R . The tutorial is structured as follows: Example Data Change Legend Text with...

### Change Position of ggplot Title in R (4 Examples) | Adjust to Center, Right-Aligned or Vertical Positioning

Change Position of ggplot Title in R (4 Examples) | Adjust to Center, Right-Aligned or Vertical Positioning   This article explains how to adjust the title position of a ggplot in R . The tutorial will be structured as follows: Example...

### Check if Object is Defined (exists in R) | 4 Examples: Vector, Variable, Function, Error

Check if Object is Defined (exists in R) | 4 Examples: Vector, Variable, Function, Error   In this R tutorial, I'll show you how to check whether a data object exists in your R programming environment. The tutorial is mainly relying on the...

### Check if Package is Missing and Install Automatically (R Programming Example)

Check if Package is Missing and Install Automatically (R Programming Example)   On this page you'll learn how to install missing package automatically in the R programming language . The post contains these topics: Example: Install...

### Check in R if a Directory Exists and Create if It doesn't (Programming Example)

Check in R if a Directory Exists and Create if It doesn't (Programming Example)   This R tutorial explains how to check for the existence of a directory and create a new directory if it doesn't exist . The article contains the following...

### Chi Square Distribution in R (4 Examples) | dchisq, pchisq, qchisq & rchisq Functions

Chi Square Distribution in R (4 Examples) | dchisq, pchisq, qchisq & rchisq Functions   In this R tutorial you'll learn how to apply the chi square functions . The content of the article is structured as follows: Example 1: Chi Square...

### Clear Data Object from Workspace in R (3 Examples) | rm & remove Functions

Clear Data Object from Workspace in R (3 Examples) | rm & remove Functions   In this R tutorial you'll learn how to clear specific data objects from the R workspace . The tutorials relies mainly on the rm() and remove() functions. The...

### Clear R and RStudio Console (2 Examples)

Clear R and RStudio Console (2 Examples)   This article explains how to clear the console in R and RStudio . I will show you two alternatives for clearing the console. More precisely, this article contains the following contents: Clear...

### coalesce R Function of dplyr Package (2 Examples)

coalesce R Function of dplyr Package (2 Examples)   In this article you'll learn how to apply the coalesce function of the dplyr add-on package in R programming . The table of content looks as follows: Example 1: Use coalesce Function...

### colSums, rowSums, colMeans & rowMeans in R | 5 Example Codes + Video

colSums, rowSums, colMeans & rowMeans in R | 5 Example Codes + Video   In this tutorial, I'll show you how to use four of the most important R functions for descriptive statistics: colSums, rowSums, colMeans, and rowMeans. I'll explain...

### combine R Function of dplyr Package (2 Examples)

combine R Function of dplyr Package (2 Examples)   In this R tutorial you'll learn how to apply the combine function of the dplyr add-on package . The tutorial looks as follows: Example 1: Basic Application of combine() in Comparison...

### Complete Cases in R (3 Programming Examples)

Complete Cases in R (3 Programming Examples) A complete data set (i.e. data without any missing values) is essential for many types of data analysis in the programming language R . In order to deal with missing data , it is crucial to find missing...

### Concatenate Vector of Character Strings in R (2 Examples) | How to Combine Text Cases

Concatenate Vector of Character Strings in R (2 Examples) | How to Combine Text Cases   In this article, I’ll explain how to concatenate a vector of character strings in the R programming language . The table of contents is as follows: Creating E...

### Continuous Uniform Distribution in R (4 Examples) | dunif, punif, qunif & runif Functions

Continuous Uniform Distribution in R (4 Examples) | dunif, punif, qunif & runif Functions   This page explains how to apply the uniform distribution functions in the R programming language . The content of the post is structured like this: Example...

### Convert Character to Factor in R (3 Examples)

Convert Character to Factor in R (3 Examples)   This article shows how to convert characters to factors in the R programming language . Table of contents: Example 1: Convert Character Vector to Factor Example 2: Convert Character...

### Convert Data Frame Column to Numeric in R (2 Examples) | Change Factor, Character & Integer

Convert Data Frame Column to Numeric in R (2 Examples) | Change Factor, Character & Integer   In this R tutorial, I'll explain how to convert a data frame column to numeric in R . No matter if you need to change the class of factors, characters,...

### Convert Data Frame Column to Vector in R (3 Examples)

Convert Data Frame Column to Vector in R (3 Examples)   In this article you'll learn how to convert a data frame column to a vector in R programming . The tutorial contains three examples for the conversion of data frame columns. To be...

### Convert Date to Day of Week in R (3 Examples) | How to Find the Weekday

Convert Date to Day of Week in R (3 Examples) | How to Find the Weekday   In this article, I'll explain how to find the weekday of a date in R . The tutorial is structured as follows Creation of Example Data in R Find Weekday...

### Convert Date to Numeric Time Object in R (Example)

Convert Date to Numeric Time Object in R (Example)   In this tutorial, I'll explain how to transform a date to a time object in R programming . Furthermore, I'll show how to extract the hours, minutes, and seconds of this date object . Table...

### Convert List of Vectors to Data Frame in R (2 Examples)

Convert List of Vectors to Data Frame in R (2 Examples)   This tutorial explains how to convert a list of vectors to a data frame in the R programming language . Table of contents: Creating Example Data Example 1: Convert List...

### Convert Table to Data Frame in R (Example)

Convert Table to Data Frame in R (Example)   In this R programming tutorial you'll learn how to convert a table to a data.frame . The page looks as follows: Creation of Example Data Example: Converting table to data.frame Video,...

### Count NA Values in R (3 Examples)

Count NA Values in R (3 Examples)   In this R tutorial you'll learn how to determine the number of NA values in a vector or data frame column. The page is structured as follows: Example 1: Count NA Values in Vector Example 2:...

### Count TRUE Values in Logical Vector in R (2 Examples)

Count TRUE Values in Logical Vector in R (2 Examples)   This article shows how to count the number of TRUE values in a logical vector in the R programming language . The tutorial will consist of two examples for the counting of TRUEs....

### Count Unique Values in R (3 Examples) | Frequency of Vector or Column

Count Unique Values in R (3 Examples) | Frequency of Vector or Column   In this R tutorial you'll learn how to count the frequency of unique values of a vector or data frame column. The tutorial looks as follows: Example Data Example...

### Create a Histogram in Base R (8 Examples) | hist Function Tutorial

Create a Histogram in Base R (8 Examples) | hist Function Tutorial   In this R tutorial you'll learn how to draw histograms with Base R . The article will consist of eight examples for the creation of histograms in R. To be more precise,...

### Create Empty Data Frame in R (2 Examples)

Create Empty Data Frame in R (2 Examples)   In this article, I'll explain how to create an empty data frame in the R programming language . I will show you two programming alternatives for the creation of an empty data frame. More precisely,...

### Create ggplot2 Histogram in R (7 Examples) | geom_histogram Function

Create ggplot2 Histogram in R (7 Examples) | geom_histogram Function   This page shows how to create histograms with the ggplot2 package in R programming . The tutorial will contain the following: Creation of Example Data & Setting...

### Create Heatmap in R (3 Examples) | Base R, ggplot2 & plotly Package

Create Heatmap in R (3 Examples) | Base R, ggplot2 & plotly Package   In this post you'll learn how to draw heatmaps in the R programming language . The content of the article is structured as follows: Construction of Example Data...

### Create Kernel Density Plot in R (7 Examples) | density() Function

Create Kernel Density Plot in R (7 Examples) | density() Function   In this R tutorial you'll learn how to draw a kernel density plot . Table of contents: Creation of Example Data Example 1: Basic Kernel Density Plot in Base R...

### Create Legend in ggplot2 Plot in R (2 Examples)

Create Legend in ggplot2 Plot in R (2 Examples)   In this article you'll learn how to add a legend to a ggplot2 plot in the R programming language . The table of content is structured as follows: Creation of Example Data & Setting...

### Create List of Data Frames in R (Example)

Create List of Data Frames in R (Example)   This tutorial explains how to make a list of data frames in the R programming language . The table of content looks as follows: Example Data Example: How to Create a List of Data Frames...

### cumall, cumany & cummean R Functions of dplyr Package (3 Examples)

cumall, cumany & cummean R Functions of dplyr Package (3 Examples)   In this R tutorial you'll learn how to apply the cumall, cumany, and cummean functions of the dplyr package . The content looks as follows: Example 1: cumall Function...

### cumsum R Function Explained (Example for Vector, Data Frame, by Group & Graph)

cumsum R Function Explained (Example for Vector, Data Frame, by Group & Graph) In many data analyses, it is quite common to calculate the cumulative sum of your variables of interest (i.e. the sum of all values up to a certain position of a vector). In...

### data.table Package in R | Tutorial & Programming Examples

data.table Package in R | Tutorial & Programming Examples   The data.table R package provides tools for data manipulation and the fast aggregation of large data sets. Here you can find the documentation of the data.table package. Here...

### DescTools Package in R | Tutorial & Programming Examples

DescTools Package in R | Tutorial & Programming Examples   The DescTools R package provides tools for basic statistics and convenience wrappers for an efficient data description. tools that analyze data with robust methods. This includes...

### Determine Classes of All Data Frame Columns (2 Examples)

Determine Classes of All Data Frame Columns (2 Examples)   In this article you'll learn how to identify the data types of all variables of a data frame in the R programming language . Table of contents: Creation of Example Data Example...

### diff Function in R (2 Examples) | How to Calculate the Difference in R

diff Function in R (2 Examples) | How to Calculate the Difference in R   In this article, I'll explain how to calculate differences of a vector with the diff function in R. Let's first have a look at the basic R syntax and the definition...

### dir R Function | 3 Example Codes

dir R Function | 3 Example Codes   Basic R Syntax: dir(path)   The dir R function returns a character vector of file and/or folder names within a directory . The basic syntax for dir in R is illustrated above. In the following...

### Disable Scientific Notation in R (2 Examples) | How to Prevent Exponential Numbers

Disable Scientific Notation in R (2 Examples) | How to Prevent Exponential Numbers   In this tutorial, you will learn how to disable scientific notation (e.g. e+10) in the R programming language . The article will be structured as follows: Creation...

### distinct R Function of dplyr Package (Example)

distinct R Function of dplyr Package (Example)   In this post you'll learn how to retain only unique rows of a data set with the distinct function of the dplyr package in R . Table of contents: Creation of Example Data Example:...

### dplyr Package in R | Tutorial & Programming Examples

dplyr Package in R | Tutorial & Programming Examples   The dplyr R package provides many tools for the manipulation of data in R. The dplyr package is part of the tidyverse environment . Here you can find the documentation of the dplyr...

### Draw Legend Outside of Plot Area in Base R Graphic (Example Code)

Draw Legend Outside of Plot Area in Base R Graphic (Example Code)   On this page you'll learn how to draw a legend outside of the plotting area of a Base R graphic in the R programming language . Table of contents: Introducing Example...

### Draw Multiple ggplot2 Plots Side-by-Side (R Programming Example)

Draw Multiple ggplot2 Plots Side-by-Side (R Programming Example)   In this R programming tutorial you'll learn how to draw multiple ggplots side-by-side . The article is structured as follows: Create Example Data Create & Store...

### Draw Multiple Graphs & Lines in Same Plot in R (Example)

Draw Multiple Graphs & Lines in Same Plot in R (Example)   This article shows how to draw several graphs in the same plot window in the R programming language . The R tutorial is structured as follows: Step 1: Draw Plot in R Step...

### droplevels R Example | How to Drop Factor Levels of Vector & Data Frame

droplevels R Example | How to Drop Factor Levels of Vector & Data Frame   Basic R Syntax: droplevels(x)   The droplevels R function removes unused levels of a factor . The function is typically applied to vectors or data frames....

### ecdf in R (Example) | Compute & Plot the Empirical Cumulative Distribution Function

ecdf in R (Example) | Compute & Plot the Empirical Cumulative Distribution Function   This tutorial shows how to compute and plot an Empirical Cumulative Distribution Function (ECDF) in the R programming language . The article is mainly...

### Exponential Distribution in R (4 Examples) | dexp, pexp, qexp & rexp Functions

Exponential Distribution in R (4 Examples) | dexp, pexp, qexp & rexp Functions   This tutorial explains how to apply the exponential functions in the R programming language . The content of the article looks as follows: Example 1:...

### Export CSV File without Row Names in R (Example)

Export CSV File without Row Names in R (Example)   In this tutorial you'll learn how to export a csv file without row names in R . Table of contents: Creation of Example Data Example: write.csv without Row Names Video & Further...

### Extract Certain Columns of Data Frame in R (4 Examples)

Extract Certain Columns of Data Frame in R (4 Examples)   This article explains how to extract specific columns of a data set in the R programming language . I will show you four programming alternatives for the selection of data frame...

### Extract Column of dplyr Tibble in R (Example)

Extract Column of dplyr Tibble in R (Example)   This article shows how to extract a certain tibble column as vector in R . The article will consist of the following contents: Creation of Example Data Example: Extract Column from...

### Extract Default Color Palette of ggplot2 R Package (Example)

Extract Default Color Palette of ggplot2 R Package (Example)   This tutorial shows how to emulate the ggplot2 default color palette in the R programming language . The content of the page looks as follows: Creation of Example Data...

### Extract First or Last n Characters from String in R (3 Examples) | Get Leading & Trailing Chars

Extract First or Last n Characters from String in R (3 Examples) | Get Leading & Trailing Chars   In this tutorial, I will explain how to extract n leading or trailing characters from a string in R. I will structure the article as follows: Creation...

### F Distribution in R (4 Examples) | df, pf, qf & rf Functions

F Distribution in R (4 Examples) | df, pf, qf & rf Functions   In this article, I'll illustrate how to apply the F distribution functions in the R programming language . The tutorial will contain this: Example 1: F Density in R (df...

### filter R Function of dplyr Package (Example)

filter R Function of dplyr Package (Example)   This article illustrates how to subset rows by logical conditions with the filter function of the dplyr package in R programming . Table of contents: Creation of Example Data Example:...

### Find Common Elements from Multiple Vectors in R (Example)

Find Common Elements from Multiple Vectors in R (Example)   In this article, I'll show how to identify shared elements of multiple vectors in the R programming language . Table of contents: Creating Example Data Example: Find Common...

### Find Index of Element in Vector in R (2 Examples)

Find Index of Element in Vector in R (2 Examples)   In this article, I'll show how to find the index of an element in a vector in the R programming language . The tutorial will contain this content: Example Data Example 1: Find...

### Find Index of Maximum & Minimum Value of Vector & Data Frame Row in R (2 Examples)

Find Index of Maximum & Minimum Value of Vector & Data Frame Row in R (2 Examples)   In this article you'll learn how to identify the index of maxima and minima of vectors and data frames in the R programming language . The tutorial will...

### Find Out Which Package Version is Loaded in R (Example Code)

Find Out Which Package Version is Loaded in R (Example Code)   The following R programming syntax illustrates how to find out the package version which is currently loaded in R . For this tutorial, I'm going to use the dplyr package ....

### Format Number of Decimal Places in R (2 Example Codes)

Format Number of Decimal Places in R (2 Example Codes)   This tutorial explains how to control the number of decimal places within the R programming language . The table of contents looks as follows: Creating Example Data Control...

### Gamma Distribution in R (4 Examples) | dgamma, pgamma, qgamma & rgamma Functions

Gamma Distribution in R (4 Examples) | dgamma, pgamma, qgamma & rgamma Functions   This article illustrates how to apply the gamma functions in the R programming language . The post is structured as follows: Example 1: Gamma Density...

### Geometric Distribution in R (4 Examples) | dgeom, pgeom, qgeom & rgeom Functions

Geometric Distribution in R (4 Examples) | dgeom, pgeom, qgeom & rgeom Functions   This tutorial shows how to apply the geometric functions in the R programming language . The tutorial contains four examples for the geom R commands. More...

### Geometric Mean in R (2 Examples)

Geometric Mean in R (2 Examples)   This post explains how to compute the geometric mean in the R programming language . This article contains two examples including reproducible R codes. So without further ado, let's move on to the...

### Get Frequency of Elements with Certain Value in Vector (2 R Programming Examples)

Get Frequency of Elements with Certain Value in Vector (2 R Programming Examples)   In this tutorial, I'll explain how to count the number of elements with a certain value in the R programming language . I will show you two programming...

### Get Last Value of Vector in R (2 Examples)

Get Last Value of Vector in R (2 Examples)   In this R tutorial you'll learn how to access the last value in a vector . The article is structured as follows: Creation of Example Data Access Last Value with length Function Access...

### GGally Package in R | Tutorial & Programming Examples

GGally Package in R | Tutorial & Programming Examples   The GGally R package is an extension of the ggplot2 package and adds several additional functions for the plotting of data in R. Here you can find the CRAN page of the GGally package....

### Graphics in R (Gallery with Examples)

Graphics in R (Gallery with Examples)   This page shows an overview of (almost all) different types of graphics, plots, charts, diagrams, and figures of the R programming language . Here is a list of all graph types that are illustrated...

### grep & grepl R Functions (3 Examples) | Match One or Multiple Patterns in Character String

grep & grepl R Functions (3 Examples) | Match One or Multiple Patterns in Character String   This tutorial explains how to search for matches of certain character pattern in the R programming language. The article is mainly based on the...

### Harmonic Mean in R (2 Examples)

Harmonic Mean in R (2 Examples)   This page shows how to compute the harmonic mean in the R programming language . I will show based on two reproducible examples how to calculate the harmonic mean for a numeric vector or a data frame...

### How to Combine Lists in R (2 Examples)

How to Combine Lists in R (2 Examples)   This article shows how to append two lists in the R programming language . The content of the page looks as follows: Construction of Example Data Example: Append Two Lists in R with c()...

### How to Convert a Character to Numeric in R

How to Convert a Character to Numeric in R   Basic R Syntax: x_num

### How to Convert a Factor to Numeric in R

How to Convert a Factor to Numeric in R   Basic R Syntax: x_num

### How to Create a Range of Dates in R (Example)

How to Create a Range of Dates in R (Example)   In this post you'll learn how to generate a date range in R programming . The page contains these contents: Example: Generating a Range of Dates in R Video & Further Resources ...

### How to Create a Venn Diagram in R (8 Examples)

How to Create a Venn Diagram in R (8 Examples)   This article illustrates how to draw venn diagrams in the R programming language . Venn diagrams are also referred to as primary diagram, set diagram, or logic diagram. Table of contents: Setting...

### How to Rename a Column Name in R | 3 Examples to Change Colnames of a Data Frame

How to Rename a Column Name in R | 3 Examples to Change Colnames of a Data Frame   Basic R Syntax: # Change colname of one column colnames(data)[colnames(data) == "Old_Name"]

### How to Save a Data Frame in R (Example)

How to Save a Data Frame in R (Example)   In this article, I'll show how to save a data frame in R programming . Table of contents: Introduction of Example Data Example: Save Data Frame in R Video, Further Resources & Summary...

How to Use R to Download File from Internet (Example)   In this article, I'll explain how to use the R programming language to download a file from the internet. Let's dive right in!   Step 1: Get URL of File First, we...

### Hypergeometric Distribution in R (4 Examples) | dhyper, phyper, qhyper & rhyper Functions

Hypergeometric Distribution in R (4 Examples) | dhyper, phyper, qhyper & rhyper Functions   This article explains how to use the hypergeometric functions in the R programming language . The post is structured as follows: Example 1:...

### if_else R Function of dplyr Package (2 Examples)

if_else R Function of dplyr Package (2 Examples)   In this tutorial you'll learn how to apply the if_else function of the dplyr package in R programming . Table of contents: Example 1: Basic Application of if_else Function Example...

### Import & Merge Multiple csv Files in R (Example)

Import & Merge Multiple csv Files in R (Example)   In this article, I'll show you how to import and merge csv files in the R programming language . The page will contain the following topics: Exemplifying Data Import & Load csv...

### Increase Font Size in Base R Plot (5 Examples)

Increase Font Size in Base R Plot (5 Examples)   In this article you'll learn how to increase font sizes in a plot in the R programming language . The page contains these contents: Creation of Example Data Example 1: Increase Font...

### IQR Function in R (2 Examples) | How to Compute the Interquartile Range

IQR Function in R (2 Examples) | How to Compute the Interquartile Range   This article explains how to compute an Interquartile Range (IQR) in the R programming language . The tutorial is mainly based on the IQR() R function. So let's...

### Join Data Frames with the R dplyr Package (9 Examples)

Join Data Frames with the R dplyr Package (9 Examples)   In this R programming tutorial, I will show you how to merge data with the join functions of the dplyr package . More precisely, I'm going to explain the following functions: inner_join...

### lead & lag R Functions of dplyr Package (2 Examples)

lead & lag R Functions of dplyr Package (2 Examples)   This tutorial shows how to apply the lead and lag functions of the dplyr add-on package in the R programming language . Table of contents: Example Data Example 1: Basic Application...

### List All Files with Specific Extension in R (Example) | list.files Function

List All Files with Specific Extension in R (Example) | list.files Function   In this tutorial, I'll illustrate how to return a list with all file names of a directory containing a certain pattern in R programming . The content looks as...

### List of Useful R Packages

List of Useful R Packages   The R programming language provides a huge list of different R packages , containing many tools and functions for statistics and data science. This page shows a list of useful R packages and libraries. By clicking...

### Load Multiple Packages at Once in R (Example)

Load Multiple Packages at Once in R (Example)   In this tutorial, I'll illustrate how to load several add-on packages with one line of code in the R programming language . The article consists of these content blocks: Creation of...

### Log Normal Distribution in R (4 Examples) | dlnorm, plnorm, qlnorm & rlnorm Functions

Log Normal Distribution in R (4 Examples) | dlnorm, plnorm, qlnorm & rlnorm Functions   This tutorial shows how to apply the log normal functions in R . The page consists of this content: Example 1: Log Normal Probability Density...

### Logistic Distribution in R (4 Examples) | dlogis, plogis, qlogis & rlogis Functions

Logistic Distribution in R (4 Examples) | dlogis, plogis, qlogis & rlogis Functions   In this R tutorial you'll learn how to apply the logistic functions . The article contains this information: Example 1: Logistic Density in R (dlogis...

### lowess() R Smoothing Function | 2 Example Codes for Normalization by Lowess Regression

lowess() R Smoothing Function | 2 Example Codes for Normalization by Lowess Regression   Basic R Syntax: lowess_values

### match Function in R (4 Example Codes)

match Function in R (4 Example Codes)   This tutorial shows how to search for matches between two data objects in the R programming language. The article is mainly based on the match() R function . The basic R syntax and the definition...

### matrixStats Package in R | Tutorial & Programming Examples

matrixStats Package in R | Tutorial & Programming Examples   The matrixStats R package provides high-performing tools for operating on rows and columns of data matrices. Here you can find the documentation of the matrixStats package....

### Mean by Group in R (2 Examples) | dplyr Package vs. Base R

Mean by Group in R (2 Examples) | dplyr Package vs. Base R   In this tutorial you'll learn how to compute the mean by group in the R programming language . I'll show two different alternatives including reproducible R codes. Let's...

### mean Function in R (4 Examples)

mean Function in R (4 Examples)   In this article you'll learn how to compute the mean in R . The tutorial is mainly based on the mean() function. Let's have a look at the basic R syntax and the definition of the mean function first:   Basic...

### Measuring Execution Time of Function in R (Example Code)

Measuring Execution Time of Function in R (Example Code)   In this tutorial, I'll illustrate how to check the execution time of a function in R programming . The tutorial will contain the following information: Example: Measuring...

### Median Absolute Deviation in R (Example) | mad Function Explained

Median Absolute Deviation in R (Example) | mad Function Explained   In this article, I'll explain how to compute the median absolute deviation in the R programming language . The tutorial is mainly relying on the mad R function . The basic...

### Median in R (5 Examples)

Median in R (5 Examples)   This tutorial shows how to compute the median in R . The article is mainly based on the median() function. So let's have a look at the basic R syntax and the definition of the median function first:   Basic...

### Merge Data Frames by Column Names in R (3 Examples)

Merge Data Frames by Column Names in R (3 Examples)   In this R post you'll learn how to merge data frames by column names . The tutorial consists of three examples for the merging of different data sets. More precisely, the article consists...

### Merge Data Frames by Row Names in R (Example)

Merge Data Frames by Row Names in R (Example)   In this R programming article you'll learn how to merge data frames by row names . The content of the post is structured as follows: Constructing Example Data Merge Data Frames by...

### Merge Time Series in R (Example)

Merge Time Series in R (Example)   In this R tutorial, I'll explain how to merge two time series objects in the R programming language . The tutorial will contain the following contents: Example Data Merge Time Series in R Video...

### Merge Two Lists in R (Example)

Merge Two Lists in R (Example)   This page shows how to merge two lists in the R programming language . Note that this article aims to merge two lists (i.e. if the elements of both lists have the same name the two elements will be combined)....

### Mode in R (4 Programming Examples)

Mode in R (4 Programming Examples)   In this tutorial, I'll explain how to compute the mode in R . The article contains four examples for different data scenarios. So without further ado, let's jump right to the examples.   Example...

### mutate & transmute R Functions of dplyr Package (2 Example Codes)

mutate & transmute R Functions of dplyr Package (2 Example Codes)   This article illustrates how to add new variables to data sets with the mutate & transmute functions of the dplyr package in the R programming language . The post is...

### NA Omit in R | 3 Example Codes for na.omit (Data Frame, Vector & by Column)

NA Omit in R | 3 Example Codes for na.omit (Data Frame, Vector & by Column)   Basic R Syntax: na.omit(data)   The na.omit R function removes all incomplete cases of a data object (typically of a data frame, matrix or vector)....

### na_if R Function of dplyr Package (2 Examples) | Convert Value to NA

na_if R Function of dplyr Package (2 Examples) | Convert Value to NA   In this article you'll learn how to replace NA values with the na_if function of the dplyr add-on package in the R programming language . The article will contain this: Example...

### NaN in R Explained (Example Code) | is.nan Function, Count, Replace & Remove

NaN in R Explained (Example Code) | is.nan Function, Count, Replace & Remove   In the R programming language , NaN stands for Not a Number . This article explains how to deal with NaN values in R. This includes the application of the...

### near R Function of dplyr Package (2 Examples)

near R Function of dplyr Package (2 Examples)   In this article, I'll illustrate how to compare numeric vectors with the near function of the dplyr package in R programming . The post is structured as follows: Creating Exemplifying...

### Negative Binomial Distribution in R (4 Examples) | dnbinom, pnbinom, qnbinom & rnbinom Functions

Negative Binomial Distribution in R (4 Examples) | dnbinom, pnbinom, qnbinom & rnbinom Functions   This article illustrates how to use the negative binomial functions in the R programming language . The content of the article looks as...

### Normal Distribution in R (5 Examples) | dnorm, pnorm, qnorm & rnorm Functions

Normal Distribution in R (5 Examples) | dnorm, pnorm, qnorm & rnorm Functions   In this tutorial I'll introduce you to the normal distribution functions in the R programming language . Table of contents: Example 1: Normally Distributed...

### nth, first & last R Functions of dplyr Package (4 Examples)

nth, first & last R Functions of dplyr Package (4 Examples)   On this page, I'll explain how to extract certain values from a vector with the nth, first, and last functions of the dplyr package in the R programming language . The page...

### Numbering Rows within Groups of Data Frame in R (2 Examples)

Numbering Rows within Groups of Data Frame in R (2 Examples)   This article illustrates how to add a counter to each group of a data frame in the R programming language . Table of contents: Constructing Example Data Example 1:...

### openxlsx Package in R | Tutorial & Programming Examples

openxlsx Package in R | Tutorial & Programming Examples   The openxlsx R package simplifies the creation of excel files by providing an interface for the writing, styling, and editing of worksheets. Here you can find the documentation...

### Order Bars of ggplot2 Barchart in R (4 Examples)

Order Bars of ggplot2 Barchart in R (4 Examples)   In this R tutorial you'll learn how to order the bars of a ggplot2 barchart . The content is structured as follows: Creation of Example Data Example 1: Ordering Bars Manually ...

### parse, deparse & expression Functions in R | Handle Character String & Expression

parse, deparse & expression Functions in R | Handle Character String & Expression   In this tutorial I will show you how to create expressions , how to convert characters to expressions , and how to convert expressions to characters . This...

### paste & paste0 R Functions (4 Examples)

paste & paste0 R Functions (4 Examples)   This article explains how to use the paste and paste0 functions in R. First, let’s have a look at the basic R syntax and the definition of the two functions:   Basic R Syntax: paste("char1", "...

### Play Sound at End of R Script (2 Examples) | beep Function

Play Sound at End of R Script (2 Examples) | beep Function   This tutorial illustrates how to make a sound at the end of a code in the R programming language . Table of contents: Example 1: Make Beep at End of Script Example 2:...

### Plot Line in R (8 Examples) | Create Line Graph & Chart in RStudio

Plot Line in R (8 Examples) | Create Line Graph & Chart in RStudio   In this R tutorial you'll learn how to draw line graphs . The article contains eight examples for the plotting of lines. To be more specific, the article looks as follows: Creating...

### plotrix Package in R | Tutorial & Programming Examples

plotrix Package in R | Tutorial & Programming Examples   The plotrix R package contains tools for the plotting of data in R. Here you can find the documentation of the plotrix package. Here you can find the CRAN page of the plotrix...

### plyr Package in R | Tutorial & Programming Examples

plyr Package in R | Tutorial & Programming Examples   The plyr R package contains tools for data manipulation in R. Here you can find the documentation of the plyr package. Here you can find the CRAN page of the plyr package. ...

### Poisson Distribution in R (4 Examples) | dpois, ppois, qpois & rpois Functions

Poisson Distribution in R (4 Examples) | dpois, ppois, qpois & rpois Functions   In this R tutorial you'll learn how to use the poisson functions . The content is structured as follows: Example 1: Poisson Density in R (dpois Function)...

### Print Entire tibble to R Console (2 Examples)

Print Entire tibble to R Console (2 Examples)   In this tutorial you'll learn how to print a tibble to the console in the R programming language . The tutorial is structured as follows: Creation of Example Data Example 1: Display...

### Probability Distributions in R (Examples) | PDF, CDF & Quantile Function

Probability Distributions in R (Examples) | PDF, CDF & Quantile Function   This page explains the functions for different probability distributions provided by the R programming language . In general, R provides programming commands for...

### psych Package in R | Tutorial & Programming Examples

psych Package in R | Tutorial & Programming Examples   The psych R package provides tools for personality, psychometric theory and experimental psychology. Here you can find the documentation of the psych package. Here you can find...

### pull R Function of dplyr Package (2 Examples)

pull R Function of dplyr Package (2 Examples)   This article explains how to extract columns with the pull function of the dplyr add-on package in R programming . Table of contents: Creation of Example Data Example 1: Apply pull...

### quantile Function in R (6 Examples)

quantile Function in R (6 Examples)   This tutorial shows how to compute quantiles in the R programming language . The article is mainly based on the quantile() R function. So let's have a look at the basic R syntax and the definition...

### Quantile-Quantile Plot in R (4 Examples) | qqplot, qqnorm & qqline Functions | ggplot2 Package

Quantile-Quantile Plot in R (4 Examples) | qqplot, qqnorm & qqline Functions | ggplot2 Package   This tutorial explains how to draw QQplots in R programming . Table of contents: Example 1: Basic QQplot & Interpretation Example...

### R abs Function (6 Example Codes) | How to Calculate an Absolute Value

R abs Function (6 Example Codes) | How to Calculate an Absolute Value   Basic R Syntax: abs(x)   The abs R function computes the absolute value of a numeric data object . The basic syntax for abs in R is illustrated above. In...

### R Capitalize First Letter of Each Word in Character String (3 Examples)

R Capitalize First Letter of Each Word in Character String (3 Examples)   In this post, I'll explain how to capitalize the first letter of each word of a character string in the R programming language . The tutorial consists of these contents: Creation...

### R eval Function (3 Examples) | Evaluate Expressions & Character Strings

R eval Function (3 Examples) | Evaluate Expressions & Character Strings   In this R tutorial, I'll explain how to evaluate an expression with the eval function. Let's first have a look at the basic R syntax and the definition of eval:   Basic...

### R Find Missing Values (6 Examples for Data Frame, Column & Vector)

R Find Missing Values (6 Examples for Data Frame, Column & Vector) Let's face it: Missing values are an issue of almost every raw data set! If we don't handle our missing data in an appropriate way, our estimates are likely to be biased. However,...

### R Functions List (+ Examples) | All Basic Commands of the R Programming Language

R Functions List (+ Examples) | All Basic Commands of the R Programming Language   List of R Commands & Functions abs - Compute the absolute value of a numeric data object. all - Check whether all values of a logical...

### R Help - Error in if (NA) { : missing value where TRUE/FALSE needed

R Help - Error in if (NA) { : missing value where TRUE/FALSE needed   In this R tutorial you'll learn how to deal with the error message Error in if (NA) { : missing value where TRUE/FALSE needed . Table of contents: Basic Explanation:...

### R Help (2 Examples) - Warning: invalid factor level, NA generated

R Help (2 Examples) - Warning: invalid factor level, NA generated   In this tutorial, I'll illustrate how to handle the warning message invalid factor level, NA generated in R . The tutorial contains the following: Example 1: Invalid...

### R is.na Function Example (remove, replace, count, if else, is not NA)

R is.na Function Example (remove, replace, count, if else, is not NA) Well, I guess it goes without saying that NA values decrease the quality of our data. Fortunately, the R programming language provides us with a function that helps us to deal...

### R max and min Functions | 8 Examples: Remove NA Value, Two Vectors, Column & Row

R max and min Functions | 8 Examples: Remove NA Value, Two Vectors, Column & Row   In this article, you will learn how to use min and max in R. I'm going to explain both functions in the same tutorial, since the R syntax of the two functions...

### R Merge Multiple Data Frames in List (2 Examples) | Base R vs. tidyverse

R Merge Multiple Data Frames in List (2 Examples) | Base R vs. tidyverse   On this page you'll learn how to simultaneously merge multiple data frames in a list in the R programming language . The tutorial will contain two examples or more...

### R NA – What are <Not Available> Values?

R NA – What are <Not Available> Values? Your data contains NA, <NA>, or NaN values? That's not the end of the world -- but your alarm bells should start ringing! In R (or R Studio) , NA stands for Not Available . Each cell of your d...

### R outer Function | 4 Example Codes (Basic Application & User Defined)

R outer Function | 4 Example Codes (Basic Application & User Defined)   Basic R Syntax: outer(x, y, "*")   The R outer function applies a function to two arrays . The basic R code for the outer command is shown above. In...

### R pairs & ggpairs Plot Functions | 5 Example Codes (Color, Labels, Panels & by Group)

R pairs & ggpairs Plot Functions | 5 Example Codes (Color, Labels, Panels & by Group)   Basic R Syntax: pairs(data)   The pairs R function returns a plot matrix, consisting of scatterplots for each variable-combination of...

### R polygon Function | 6 Example Codes (Frequency & Density Plot)

R polygon Function | 6 Example Codes (Frequency & Density Plot)   Basic R Syntax: polygon(x_coordinates, y_coordinates)   The R polygon function draws a polygon to a plot . The basic R syntax for the polygon command is illustrated...

### R pretty Function | 3 Example Codes (Interval Sequence & Set Axis Labels of Plot)

R pretty Function | 3 Example Codes (Interval Sequence & Set Axis Labels of Plot)   Basic R Syntax: pretty(x)   The pretty R function computes a sequence of equally spaced round values . The basic R syntax for the pretty command...

### R Replace Last Comma of Character with &-Sign (5 Examples)

R Replace Last Comma in Character with &-Sign (5 Examples) If you are working with text data, you will often have a list or enumeration of words that is separated by commas, e.g.: "Ball, Animal, Beer, Pig, Wagon, Balloon, Hero" The last comma...

### R Replace NA with 0 (10 Examples for Data Frame, Vector & Column)

R Replace NA with 0 (10 Examples for Data Frame, Vector & Column) A common way to treat missing values in R is to replace NA with 0. You will find a summary of the most popular approaches in the following. Choose one of these approaches according...

### R scan Function (5 Example Codes) | Read Text or CSV File Line by Line

R scan Function (5 Example Codes) | Read Text or CSV File Line by Line   In this article, I'll explain how to use the scan function to read data into R . Let's first have a look at the basic R syntax and the definition of scan():   Basic...

### R sink Function (3 Examples) | Export R output as txt & csv File

R sink Function (3 Examples) | Export R output as txt & csv File   In this article, I'll explain how to use the sink function in R. I'll show you in three examples how to: print text to a txt file (Example 1) export data as txt...

### R substr & substring Functions | Examples: Remove, Replace, Match in String

R substr & substring Functions | Examples: Remove, Replace, Match in String   In this R tutorial, I'll show you how to apply the substr and substring functions . I'll explain both functions in the same article, since the R syntax and the output...

### R sweep Function | 3 Example Codes (Matrix Operation with MARGIN & STATS)

R sweep Function | 3 Example Codes (Matrix Operation with MARGIN & STATS)   Basic R Syntax: sweep(x = data, MARGIN = 1, STATS = 1, FUN = "+")   The sweep R function applies an operation (e.g. + or -) to a data matrix by row...

### R transform Function (2 Example Codes) | Transformation of Data Frames

R transform Function (2 Example Codes) | Transformation of Data Frames   In this tutorial, I'll explain you how to modify data with the transform function. Let's first have a look at the basic R syntax and the definition of the function:   Basic...

### R union Function | 3 Example Codes (Two Vectors, Data Frames & Lists)

R union Function | 3 Example Codes (Two Vectors, Data Frames & Lists)   Basic R Syntax: union(x1, x2)   In R , the union function returns all values that appear in at least one of two data objects (usually vectors). Each value...

### R unlist Function | 3 Example Codes (List of Vectors, Data Frame & String)

R unlist Function | 3 Example Codes (List of Vectors, Data Frame & String)   Basic R Syntax: unlist(my_list)   The unlist R function converts a list to a single vector. The basic code for unlist in R is illustrated above. In...

### Random Numbers in R (2 Examples) | Draw Randomly from Probability Distribution & Given Data

Random Numbers in R (2 Examples) | Draw Randomly from Probability Distribution & Given Data   In this article, I'll explain how to draw random numbers in R programming . Table of contents: Example 1: Draw Random Numbers from Probability...

### Rank Functions of dplyr Package in R (row_number, ntile, min_rank, dense_rank, percent_rank & cume_dist)

Rank Functions of dplyr Package in R (row_number, ntile, min_rank, dense_rank, percent_rank & cume_dist)   In this tutorial, I'll illustrate how to apply the rank functions of the dplyr package in the R programming language . The rank functions...

### rbind in R | 3 Examples (Vector, Data Frame & rbind.fill for Missing Columns)

rbind in R | 3 Examples (Vector, Data Frame & rbind.fill for Missing Columns)   Basic R Syntax: rbind(my_data, new_row)   The name of the rbind R function stands for row-bind . The rbind function can be used to combine several...

### Read xlsx & xls Excel File in R (6 Examples)

Read xlsx & xls Excel File in R (6 Examples)   This tutorial explains how to read Excel files in R . More precisely, I will show you how to: Read an xlsx File with the read.xlsx Function of the xlsx Package (Example 1 ) Read an...

### reader Package in R | Tutorial & Programming Examples

reader Package in R | Tutorial & Programming Examples   The reader R package provides simplified tools for the reading of data from files. Here you can find the CRAN page of the reader package.   Tutorials on the reader...

readLines, n.readLines & readline in R (6 Example Codes)   In this tutorial, I’m going to show you how to read text by line with three different R functions : readLines (Examples 1-4) n.readLines (Example 5) readline (Example 6) ...

### readxl Package in R | Tutorial & Programming Examples

readxl Package in R | Tutorial & Programming Examples   The readxl R package provides tools for the import of excel files into R. The readxl package is part of the tidyverse environment . Here you can find the documentation of the readxl...

### recode & recode_factor R Functions of dplyr Package (2 Examples)

recode & recode_factor R Functions of dplyr Package (2 Examples)   In this article you'll learn how to replace certain values with the recode and recode_factor functions of the dplyr package in R . The article looks as follows: Example...

### Remove Axis Labels & Ticks of ggplot2 Plot (R Programming Example)

Remove Axis Labels & Ticks of ggplot2 Plot (R Programming Example)   This tutorial illustrates how to delete axis labels and ticks of a ggplot2 plot in R . The article will consist of one examples for the removal of axis information. To...

### Remove Axis Values of Plot in Base R (3 Examples)

Remove Axis Values of Plot in Base R (3 Examples)   In this tutorial, I'll show how to remove axis values of a plot in Base R . The article contains three examples for the removal of axis values. To be more precise, the tutorial contains...

### Remove Duplicated Rows from Data Frame in R (Example)

Remove Duplicated Rows from Data Frame in R (Example)   This tutorial illustrates how to eliminate duplicated rows from a data frame in R programming . Table of contents: Creation of Example Data Example: Delete Duplicated Rows...

### Remove Element from List in R (7 Example Codes) | How to Delete a List Component

Remove Element from List in R (7 Example Codes) | How to Delete a List Component   In this tutorial, I will show you how to remove one or multiple elements from a list in R . The article is structured as follows: Creating an Example...

### Remove Legend in ggplot2 (3 Example Codes) | Delete One or All Legends

Remove Legend in ggplot2 (3 Example Codes) | Delete One or All Legends   This tutorial shows how to remove legends in plots of the R ggplot2 package . The article is structured as follows: Creating Example Data Hide All Legends...

### Remove NA Values from Vector in R (2 Examples)

Remove NA Values from Vector in R (2 Examples)   In this article you'll learn how to remove NA values from a vector in the R programming language . Table of contents: Creation of Example Data Example 1: Create New Vector without...

### Reorder Columns of Data Frame in R (4 Examples)

Reorder Columns of Data Frame in R (4 Examples)   In this tutorial, I'll explain how to manually order the variables of a data frame in the R programming language . The tutorial will contain these topics: Creation of Example Data...

### Replace NA with Last Observed Value in R (Example)

Replace NA with Last Observed Value in R (Example)   In this R tutorial you'll learn how to replace NAs with the previous non-NA value . Table of contents: Creation of Example Data Example: Replace NA with latest non-NA Value in...

### Reshape Data Frame from Wide to Long Format in R (2 Examples)

Reshape Data Frame from Wide to Long Format in R (2 Examples)   In this tutorial, I'll illustrate how to convert a data frame from wide to long format in the R programming language . The post contains the following topics: Example...

### Return Multiple Objects from User-Defined Function in R (Example)

Return Multiple Objects from User-Defined Function in R (Example)   This tutorial illustrates how to return multiple outputs from a user-defined function in R . The tutorial consists of the following content blocks: Create User-Defined...

### Return Value from R Function (3 Examples)

Return Value from R Function (3 Examples)   This article shows how to apply the return command to produce outputs with user-defined R functions . The article contains three reproducible examples: Example 1: R Function with return Example...

### rev R Function | 3 Examples (Reverse of Vector, Data Frame by Column & by Row)

rev R Function | 3 Examples (Reverse of Vector, Data Frame by Column & by Row)   Basic R Syntax: rev(x)   The rev R function returns a reversed version of a vector or other data objects . The basic R code for the rev command...

### robustbase Package in R | Tutorial & Programming Examples

robustbase Package in R | Tutorial & Programming Examples   The robustbase R package provides tools that analyze data with robust methods. This includes methodology for model selection and multivariate statistics. Here you can find the...

### Rotate Axis Labels of Base R Plot (3 Examples)

Rotate Axis Labels of Base R Plot (3 Examples)   In this article, I'll explain how to rotate axis labels of a Base R plot in the R programming language . The content of the post is structured as follows: Example Data Example 1:...

### Rotate ggplot2 Axis Labels in R (2 Examples)

Rotate ggplot2 Axis Labels in R (2 Examples)   This article explains how to rotate the axis labels of a ggplot in the R programming language . The article contains the following topics: Creation of Example Data & Basic Plot Example...

### Rounding in R (4 Examples) | round, ceiling, floor, trunc & signif Functions

Rounding in R (4 Examples) | round, ceiling, floor, trunc & signif Functions   This tutorial explains how to round numbers in R with the functions round(), ceiling(), floor(), trunc(), and signif(). The article shows in four examples ...

### Sample Random Rows of Data Frame in R (2 Examples) | Select with Base R vs. dplyr Package

Sample Random Rows of Data Frame in R (2 Examples) | Select with Base R vs. dplyr Package   This tutorial illustrates how to select random rows in a data frame in the R programming language . The article will consist of the following information: Construction...

### sample_n & sample_frac R Functions | Sample Data with dplyr Package

sample_n & sample_frac R Functions | Sample Data with dplyr Package   This article shows how to take a sample of a data set with the sample_n and sample_frac functions of the dplyr package in the R programming language . The post is structured...

### Save & Load RData Workspace Files in R (3 Examples)

Save & Load RData Workspace Files in R (3 Examples)   This article shows how to save and load data from and to R . In the article, I'll show in three examples how to: Save & Load the Whole Workspace (save.image Function) Save &...

### SDMTools Package in R | Tutorial & Programming Examples

SDMTools Package in R | Tutorial & Programming Examples   The SDMTools R package provides tools for the post processing of outcomes of species distribution modeling exercises. Here you can find the documentation of the SDMTools package....

### select & rename R Functions of dplyr Package (2 Examples)

select & rename R Functions of dplyr Package (2 Examples)   In this R tutorial you'll learn how to select and rename variables with the select() and rename() functions of the dplyr package . The tutorial consists of two examples for the...

### Select Only Numeric Columns from Data Frame in R (Example)

Select Only Numeric Columns from Data Frame in R (Example)   In this tutorial, I'll explain how to subset only numeric variables from a data frame in the R programming language . The article consists of these contents: Creation of...

### Set Axis Limits in ggplot2 R Plot (3 Examples)

Set Axis Limits in ggplot2 R Plot (3 Examples)   This tutorial explains how to set the axis limits of a ggplot in the R programming language . The article consists of the following contents: Creation of Example Data & Basic Plot...

### setNames vs. setnames in R (+ Examples) | stats & data.table Package

setNames vs. setnames in R (+ Examples) | stats & data.table Package   In this R tutorial, I'll show you how to apply the setNames function of the R package stats and the setnames function of the R package data.table. The two functions are...

### Simulate Bivariate & Multivariate Normal Distribution in R (2 Examples)

Simulate Bivariate & Multivariate Normal Distribution in R (2 Examples)   This post explains how to draw a random bivariate and multivariate normal distribution in the R programming language . Table of contents: Example 1: Bivariate...

### slice R Function of dplyr Package (Example)

slice R Function of dplyr Package (Example)   In this tutorial you'll learn how to extract certain rows of a data set with the slice function of the dplyr package in the R programming language . The article will contain these contents: Creation...

### Sort Data Frame by Multiple Columns in R (3 Examples)

Sort Data Frame by Multiple Columns in R (3 Examples)   This tutorial illustrates how to order a data frame by multiple columns in the R programming language . I will show you three example codes for the sorting of data frames . More...

### Sort Data Frame in R (4 Examples)

Sort Data Frame in R (4 Examples)   This article explains how to sort a data frame in the R programming language . I will show you four different examples for the ordering of data frames. More precisely, the tutorial will contain the...

### sort, order & rank R Functions | 6 Examples: Data Table, List & by Group Column

sort, order & rank R Functions | 6 Examples: Data Table, List & by Group Column   This article explains how to sort data in R with the functions sort(), order(), and rank(). The tutorial shows in six examples how the different sorting...

### sprintf R Function (6 Example Codes)

sprintf R Function (6 Example Codes)   This article explains how to apply the sprintf() function in R. First, let’s have a look at the basic R syntax and the definition of sprintf:   Basic R Syntax of sprintf: sprintf("%f", x...

### Square Root in R (5 Examples) | Apply sqrt Function in R Studio

Square Root in R (5 Examples) | Apply sqrt Function in R Studio   In this tutorial, I'm going to show you how to calculate the square root in R . The tutorial is mainly based on the sqrt function:   Basic R Syntax: sqrt(x)...

### Standard Deviation in R (3 Examples) | Apply sd Function in R Studio

Standard Deviation in R (3 Examples) | Apply sd Function in R Studio   This tutorial explains how to compute the standard deviation in the R programming language. The article is mainly based on the sd() R function . The basic R syntax...

### Standard Error in R (2 Examples)

Standard Error in R (2 Examples)   This tutorial explains how to compute the standard error of the mean in the R programming language . In the following, I'll show you two different example codes for the computation of the standard error...

### stats Package in R | Tutorial & Programming Examples

stats Package in R | Tutorial & Programming Examples   The stats R package provides tools for statistical calculations and the generation of random numbers. Here you can find the CRAN page of the stats package.   Tutorials...

### str_c R Function of stringr Package (3 Example Codes)

str_c R Function of stringr Package (3 Example Codes)   This R tutorial shows how to use the str_c function of the stringr package . Let's first have a look at the basic R syntax and the definition of the str_c function:   Basic...

### str_count Function in R (stringr Package)

str_count Function in R (stringr Package)   In this tutorial you'll learn how to use the str_count function to count the number of matches in a character string in R . The content of the page is structured as follows: Creation of...

### str_detect Function in R (stringr Package)

str_detect Function in R (stringr Package)   In this article you'll learn how to use the str_detect function to detect the presence or absence of a pattern in a character string in R . Table of contents: Creation of Example Data ...

### str_dup Function in R (stringr Package)

str_dup Function in R (stringr Package)   In this R tutorial you'll learn how to use the str_dup function to duplicate and concatenate strings within a character vector . The tutorial will contain this content: Creation of Example...

### str_extract Function in R (stringr Package)

str_extract Function in R (stringr Package)   In this tutorial, I'll explain how to use the str_extract function to extract matching patterns from a character string in the R programming language . Table of contents: Introduction...

### str_flatten Function in R (Example)

str_flatten Function in R (Example)   In this article you'll learn how to flatten a string with the str_flatten function in the R programming language . The article looks as follows: Creation of Exemplifying Data Example: Application...

### str_length Function in R (Example)

str_length Function in R (Example)   This article illustrates how to return the length of a string with the str_length function in the R programming language . The article contains these contents: Example Data Example: Application...

### str_locate & str_locate_all Functions in R (2 Examples)

str_locate & str_locate_all Functions in R (2 Examples)   In this R tutorial you'll learn how to use str_locate and str_locate_all to locate the position of patterns in a character string . Table of contents: Example Data Example...

### str_match & str_match_all Functions in R (2 Examples)

str_match & str_match_all Functions in R (2 Examples)   In this tutorial you'll learn how to apply str_match and str_match_all to extract matched groups from a string in R . The tutorial contains this information: Creation of Example...

### str_order & str_sort Functions in R (2 Examples)

str_order & str_sort Functions in R (2 Examples)   In this article you'll learn how to order or sort a character vector with the str_order and str_sort functions in the R programming language . The table of content is structured as follows: Creation...

### str_remove & str_remove_all Functions in R (Example)

str_remove & str_remove_all Functions in R (Example)   In this R programming tutorial you'll learn how to remove matched patterns in a character string with str_remove and str_remove_all . Table of contents: Constructing Exemplifying...

### str_replace & str_replace_all Functions in R (2 Examples)

str_replace & str_replace_all Functions in R (2 Examples)   In this post you'll learn how to replace matched patterns in character strings with the str_replace and str_replace_all functions in the R programming language . The article contains...

### str_replace_na Function in R Programming (Example)

str_replace_na Function in R Programming (Example)   In this article, I'll show how to replace NA values with str_replace_na in R programming . The post will contain these content blocks: Constructing Example Data Example 1: Default...

### str_split & str_split_fixed Functions in R (2 Examples)

str_split & str_split_fixed Functions in R (2 Examples)   This post illustrates how to use str_split and str_split_fixed to split up a string into pieces in the R programming language . Table of contents: Creation of Exemplifying...

### str_starts & str_ends Functions in R (2 Examples)

str_starts & str_ends Functions in R (2 Examples)   In this article, I'll illustrate how to apply str_starts and str_ends to detect the presence or absence of a pattern at the beginning or end of character strings in the R programming language...

### str_sub R Function of stringr Package (2 Examples)

str_sub R Function of stringr Package (2 Examples)   This R programming tutorial explains how to apply the str_sub function of the stringr package . First, let's have a look at the basic R syntax and the definition of the str_sub function:   Basic...

### str_subset & str_which Functions in R (2 Examples)

str_subset & str_which Functions in R (2 Examples)   This tutorial illustrates how use str_subset to keep only strings matching a pattern or how to apply the str_which function to find positions in a character string in the R programming...

### str_trim Function in R (Example)

str_trim Function in R (Example)   This tutorial illustrates how to use str_trim to trim whitespace from a character string in the R programming language . The content of the article is structured as follows: Creation of Example Data...

### str_trunc Function in R (Example)

str_trunc Function in R (Example)   In this tutorial you'll learn how to truncate character strings with the str_trunc function in the R programming language . Table of contents: Example Data Example: str_trunc Function in R Video,...

### str_wrap Function in R (Example)

str_wrap Function in R (Example)   In this R programming tutorial you'll learn how to apply the str_wrap function to wrap a character string into nicely formatted paragraphs. The content of the post looks as follows: Creation of...

### stringr Package in R | Tutorial & Programming Examples

stringr Package in R | Tutorial & Programming Examples   The stringr R package provides consistent wrappers for the stringi package and therefore simplifies the manipulation of character strings in R. Here you can find the documentation...

### strptime & strftime in R | 5 Example Codes (How to Set Year, Day, Hour & Time Zone)

strptime & strftime in R | 5 Example Codes (How to Set Year, Day, Hour & Time Zone)   In this article, I’ll explain how to convert characters to time objects (and the other way around). The tutorial is based on two R functions: strptime f...

### Student t distribution in R (4 Examples) | dt, pt, qt & rt Functions

Student t distribution in R (4 Examples) | dt, pt, qt & rt Functions   This article shows how to apply the Student t functions in R . The tutorial is structured as follows: Example 1: Student t Probability Density Function (dt Function)...

### Studentized Range Distribution in R (2 Examples) | ptukey & qtukey Functions

Studentized Range Distribution in R (2 Examples) | ptukey & qtukey Functions   In this tutorial, I'll explain how to apply the Studentized Range distribution functions in R . Table of contents: Example 1: Studentized Range Cumulative...

### sub & gsub R Functions (2 Examples) | Replace One or Multiple Patterns

sub & gsub R Functions (2 Examples) | Replace One or Multiple Patterns   This article explains how to replace pattern in characters in the R programming language . The tutorial is based on the R functions sub() and gsub(). Let's first...

### Subset Data Frame Rows by Logical Condition in R (5 Examples)

Subset Data Frame Rows by Logical Condition in R (5 Examples)   In this tutorial you'll learn how to subset rows of a data frame based on a logical condition in the R programming language . Table of contents: Creation of Example Data...

### Sum by Group in R (2 Examples)

Sum by Group in R (2 Examples)   In this article, I'll explain how to compute the sum by group in the R programming language . I'll show two different alternatives including reproducible R codes. More precisely, this tutorial contains...

### sum Function in R (3 Examples)

sum Function in R (3 Examples)   In this tutorial you'll learn how to compute the sum in R . The article is mainly based on the sum() function. Let's have a look at the basic R syntax and the definition of the sum function:   Basic...

### Suppress Warnings Globally in R (Example)

Suppress Warnings Globally in R (Example)   In this R tutorial you'll learn how to disable warning messages in the global options . Table of contents: Example: Disable Warning Messages in R Set Global Options to Default Video...

### Test if Vector Contains Given Element in R (Example)

Test if Vector Contains Given Element in R (Example)   This tutorial explains how to test if a vector contains a certain element in R . I will show a step by step example, which is structured as follows: Create Example Vector Check...

### The all & any R Functions | 4 Example Codes

The all & any R Functions | 4 Example Codes   In this tutorial, I'll show you how to use the all and any R functions. I'm going to combine both functions in this article, since the R syntax and the usage of the two functions are basically...

### The difftime R Function | 3 Examples (Return Time Difference in Days, Seconds or Weeks)

The difftime R Function | 3 Examples (Return Time Difference in Days, Seconds or Weeks)   Basic R Syntax: difftime(time_1, time_2)   The difftime R function calculates the time difference of two date or time objects . The...

### The dim Function in R (4 Examples)

The dim Function in R (4 Examples)   Basic R Syntax: dim(data)   The dim function of the R programming language returns the dimension (e.g. the number of columns and rows) of a matrix, array or data frame. Above, you can see...

### The get Function in R (5 Examples)

The get Function in R (5 Examples)   In this article, I'll show you how to use the get function in R . Let's first have a look at the basic R syntax and the definition of the get function:   Basic R Syntax: get("x")   Definition:...

### The is.null Function in R (4 Examples)

The is.null Function in R (4 Examples)   Basic R Syntax: is.null(x)   The R function is.null indicates whether a data object is of the data type NULL (i.e. a missing value). The function returns TRUE in case of a NULL object...

### The jitter R Function | 3 Example Codes (Basic Application & Boxplot Visualization)

The jitter R Function | 3 Example Codes (Basic Application & Boxplot Visualization)   Basic R Syntax: jitter(x)   The jitter R function adds noise to a numeric vector . Typically, this numeric vector is censored or rounded...

### The length Function in R (3 Examples for Vector, List & String)

The length Function in R (3 Examples for Vector, List & String)   Basic R Syntax: length(x)   The length function returns the length of R objects such as vectors, lists, or strings (find a little trick in Example 3). The R...

### The nchar R Function | 3 Examples (String, Vector & Error: nchar Requires a Character)

The nchar R Function | 3 Examples (String, Vector & Error: nchar Requires a Character)   Basic R Syntax: nchar(x)   The nchar R function counts the number of elements (e.g. letters) of a character object. The basic syntax...

### The ncol Function in R (3 Examples)

The ncol Function in R (3 Examples)   Basic R Syntax: ncol(data)   The ncol R function returns the number of columns of a matrix or data frame. Above, you can find the command for the application of ncol in the R programming...

### The nrow Function in R (4 Examples)

The nrow Function in R (4 Examples)   Basic R Syntax: nrow(data)   The nrow R function returns the number of rows that are present in a data frame or matrix. Above, you can find the R code for the usage of nrow in R. You...

### The pmax and pmin R Functions | 3 Examples (How to Handle Warnings & NA)

The pmax and pmin R Functions | 3 Examples (How to Handle Warnings & NA)   In this tutorial, I will show you how to use the R functions pmax() and pmin() . I'll explain both functions in the same article, since the R syntax of the two functions...

### The segments R Function | 3 Example Codes

The segments R Function | 3 Example Codes   Basic R Syntax: segments(x0 = 1, y0 = 1, x1 = 2, y1 = 2)   The segments R function draws a line segment between two pairs of points . The basic syntax for segments in R is shown above. In...

### The setdiff R Function (3 Example Codes)

The setdiff R Function (3 Example Codes)   Basic R Syntax: setdiff(x, y)   The R function setdiff indicates which elements of a vector or data frame X are not existent in a vector or data frame Y. The previous code illustrates...

### tolower, toupper, casefold & chartr R Functions (3 Examples)

tolower, toupper, casefold & chartr R Functions (3 Examples)   This article explains how to convert characters from upper to lower case or vice versa in R . In the tutorial, I will show examples for the R functions tolower(), toupper(),...

### top_n & top_frac R Functions of dplyr Package (2 Examples)

top_n & top_frac R Functions of dplyr Package (2 Examples)   In this R tutorial you'll learn how to return the upper part of a data set with the top_n and top_frac functions of the dplyr add-on package . The article consists of the following: Creating...

### Trim Leading and Trailing Whitespace in R (Example for trimws Function)

Trim Leading and Trailing Whitespace in R (Example for trimws Function)   This tutorial explains how to remove leading and trailing whitespace in the R programming language . The article is mainly based on the trimws() R function. Let's...

### type.convert R Function (Example) | Type Conversion in R Programming

type.convert R Function (2 Examples) | Type Conversion in R Programming   In this tutorial you'll learn how to apply the type.convert function in R . Let's have a look at the basic R syntax and the definition of the type.convert function...

### Unload Package without Restarting R (Example)

Unload Package without Restarting R (Example)   This tutorial explains how to unload a package without restarting R (or RStudio) . The article is structured as follows: Step 1: Install & Load Package in R Step 2: Unload Package...

### Use Function in Each Row of Data Frame in R (2 Examples)

Use Function in Each Row of Data Frame in R (2 Examples)   In this article, I'll show how to apply a function to each row of a data frame in the R programming language . Table of contents: Constructing Example Data Example 1: apply()...

### Variance in R (3 Examples) | Apply var Function with R Studio

Variance in R (3 Examples) | Apply var Function with R Studio   This tutorial shows how to compute a variance in the R programming language . The article is mainly based on the var() function. The basic R syntax and the definition of var...

### weekdays, months, quarters & julian Functions in R (4 Examples)

weekdays, months, quarters & julian Functions in R (4 Examples)   In this article, I'll explain how to apply the R programming functions weekdays, months, quarters, and julian . Let’s have a look at the basic R syntax and the definition o...

### Weibull Distribution in R (4 Examples) | dweibull, pweibull, qweibull & rweibull Functions

Weibull Distribution in R (4 Examples) | dweibull, pweibull, qweibull & rweibull Functions   In this tutorial you'll learn how to apply the weibull functions in R . Table of contents: Example 1: Weibull Density in R (dweibull Function)...

### Weighted Mean in R (5 Examples)

Weighted Mean in R (5 Examples)   This tutorial explains how to compute the weighted mean in the R programming language . The tutorial is mainly based on the weighted.mean() function. So let's have a look at the basic R syntax and the...

### Weighted Sum in R (Example)

Weighted Sum in R (Example)   This article shows in an R programming example how to compute the weighted sum . First, we need to create some example data in R. I'm going to create one numeric vector containing my observed values... x...

### Wilcoxon Signedank Statistic Distribution in R (4 Examples) | dsignrank, psignrank, qsignrank & rsignrank Functions

Wilcoxon Signedank Statistic Distribution in R (4 Examples) | dsignrank, psignrank, qsignrank & rsignrank Functions   In this tutorial, I'll show how to use the functions of the Wilcoxon Signedank Statistic in the R programming language . Table...

### Wilcoxonank Sum Statistic Distribution in R (4 Examples) | dwilcox, pwilcox, qwilcox & rwilcox Functions

Wilcoxonank Sum Statistic Distribution in R (4 Examples) | dwilcox, pwilcox, qwilcox & rwilcox Functions   This article illustrates how to apply the Wilcoxonank Sum Statistic functions in the R programming language . The table of content...

### with & within Functions in R (2 Examples)

with & within Functions in R (2 Examples)   In this R programming tutorial I'll show you how to use the with and within functions to handle data in R. Let's first have a look at the basic R syntax and the definition of with() and within():   Basic...

### Write xlsx & xls in R (4 Examples) | How to Export Data from R to Excel File

Write xlsx & xls in R (4 Examples) | How to Export Data from R to Excel File   In this article, I'll explain how to write Excel files in R . The tutorial will be based on the write.xlsx function of the xlsx package . So let's first have a...

### xlsx Package in R | Tutorial & Programming Examples

xlsx Package in R | Tutorial & Programming Examples   The xlsx R package provides tools that read, write, and format excel files. Here you can find the documentation of the xlsx package. Here you can find the CRAN page of the xlsx...

## The Increasing Popularity of R Programming

Since the R programming language provides features for almost all statistical tasks without any costs for the user, R is rapidly growing since its release. Let’s check some numbers… Graphic 1: Google Scholar Search Results for R Programming Filtered by Year

## Reasons to Learn R

The pros:

+ R is free

+ R’s popularity is growing – More and more people will use it

+ Almost all statistical methods are available in R

+ New methods are implemented in add-on packages quickly

+ Algorithms for packages and functions are publicly available (transparency and reproducibility)

+ R provides a huge variety of graphical outputs

+ R is very flexible – Essentially everything can be modified for your personal needs

+ R is compatible with all operating systems (e.g. Windows, MAC, or Linux)

+ R has a huge community that is organized in forums to help each other (e.g. stackoverflow)

+ R is fun 🙂

The cons:

– Relatively high learning burden at the beginning (even though it’s worth it)

– No systematic validation of new packages and functions

– No company in the background that takes responsibility for errors in the code (this is especially important for public institutes)

– R is almost exclusively based on programming (no extensive drop-down menus such as in SPSS)

– R can have problems with computationally intensive tasks (only important for advanced users)

You are not sure yet, whether you should learn the R programming language? In that case, I can recommend the following video of the YouTube channel RenegadeThinking. The speaker provides you with many reasons, why it is advisable to learn R.

## Appendix

Appendix 1: R code for the creation of Graphic 1

```year <- 2018:2000 # Years   r_gs <- c(21600 * 2, 43300, 43100, 38100, 33200, 29800, # Google Scholar searches 28500, 25500, 22400, 19100, 15900, 12000, 8270, 5930, 3740, 2600, 1980, 1600, 1360)   data <- data.frame(software = rep("R", 19), # Combine data year = year, searches = r_gs)   ggplot(data) + # Create plot geom_point(aes(x = year, y = searches, color = software, shape = software)) + geom_line(aes(x = year, y = searches, color = software)) + theme(legend.title = element_blank(), legend.position = "none") + ggtitle("Google Scholar Search Results") + labs(x = "Year", y = "Search Results") + scale_y_continuous(labels = comma)```

```par(mar = c(0, 0, 0, 0)) # Remove space around plot par(bg = "#1b98e0") # Set background color   set.seed(10293847) # Seed   N <- 100000 # Sample size x <- rnorm(N) # X variable y <- rnorm(N) + x # Correlated Y variable   plot(x, y, col = "#353436", pch = 19, cex = 0.1 # Create plot , xlim = c(- 4, 4), ylim = c(- 7, 7)) text(0, 0, "R", col = "#1b98e0", cex = 12) # Write R points(0, 0, col = "#1b98e0", cex = 30, lwd = 5) # Create circles points(0, 0, col = "#1b98e0", cex = 50, lwd = 5) points(0, 0, col = "#1b98e0", cex = 70, lwd = 5) points(0, 0, col = "#1b98e0", cex = 90, lwd = 5) points(0, 0, col = "#1b98e0", cex = 110, lwd = 5) box(col="#1b98e0") # Color of box```