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 statistical-programming.com

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

 

apropos & find Functions in R (2 Examples)

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...
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

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...
attach & detach Functions in R | 2 Examples: Data Frame & Package

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)

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...
break & next Functions in R for-loop (2 Examples)

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...
cbind R Command | 3 Example Codes (Data Frame, Vector & Multiple Columns)

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 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

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

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

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...
colSums, rowSums, colMeans & rowMeans in R | 5 Example Codes + Video

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...
Complete Cases in R (3 Programming Examples)

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

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...
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

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 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

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...
cumsum R Function Explained (Example for Vector, Data Frame, by Group & Graph)

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...
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

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

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

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...
droplevels R Example | How to Drop Factor Levels of Vector & Data Frame

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....
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

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...
Format Number of Decimal Places in R (2 Example Codes)

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...
Graphics in R (Gallery with Examples)

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 . Each type of graphic is illustrated with some basic example...
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

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...
How to Convert a Character to Numeric in R

How to Convert a Character to Numeric in R

How to Convert a Character to Numeric in R   Basic R Syntax: x_num   require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us18.list-manage.com","uuid":"e21bd5d10aa2be474db535a7b","lid":"841e4c86f0"})...
How to Convert a Factor to Numeric in R

How to Convert a Factor to Numeric in R

How to Convert a Factor to Numeric in R   Basic R Syntax: x_num   require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us18.list-manage.com","uuid":"e21bd5d10aa2be474db535a7b","lid":"841e4c86f0"})...
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

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 Use R to Download File from Internet (Example)

How to Use R to Download File from Internet (Example)

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...
Join Data Frames with the R dplyr Package (9 Examples)

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...
lowess() R Smoothing Function | 2 Example Codes for Normalization by Lowess Regression

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   require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us18.list-manage.com","uuid":"e21bd5d10aa2be474db535a7b","lid":"841e4c86f0"})...
match Function in R (4 Example Codes)

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...
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)

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)....
NaN in R Explained (Example Code) | is.nan Function, Count, Replace & Remove

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...
parse, deparse & expression Functions in R | Handle Character String & Expression

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)

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", "...
R abs Function (6 Example Codes) | How to Calculate an Absolute Value

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 eval Function (3 Examples) | Evaluate Expressions & Character Strings

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)

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

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 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)

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

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 NA – What are <Not Available> Values?

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)

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)

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 a...
R polygon Function | 6 Example Codes (Frequency & Density Plot)

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)

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 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)

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

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

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

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)

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

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)

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)

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...
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)

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)

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...
readLines, n.readLines & readline in R (6 Example Codes)

readLines, n.readLines & readline in R (6 Example Codes)

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) ...
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

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

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...
Return Value from R Function (3 Examples)

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)

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...
Rounding in R (4 Examples) | round, ceiling, floor, trunc & signif Functions

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 ...
Save & Load RData Workspace Files in R (3 Examples)

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 &...
setNames vs. setnames in R (+ Examples) | stats & data.table Package

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...
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

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)

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

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)...
str_c R Function of stringr Package (3 Example Codes)

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_sub R Function of stringr Package (2 Examples)

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...
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)

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...
sub & gsub R Functions (2 Examples) | Replace One or Multiple Patterns

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...
The all & any R Functions | 4 Example Codes

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)

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)

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)

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)

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)

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)

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)

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)

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)

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)

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

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)

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)

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(),...
weekdays, months, quarters & julian Functions in R (4 Examples)

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...
with & within Functions in R (2 Examples)

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

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...

 

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…

 

R Programming Language Increased Popularity

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)

 

Appendix 2: How to create the header graphic of this page

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

 



 

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu