# 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 Leading Zeros in R (Example)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### dir R Function | 3 Example Codes

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### Geometric Mean in R (2 Examples)

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

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

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

### Graphics in R (Gallery with Examples)

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

### Harmonic Mean in R (2 Examples)

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

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

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

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

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

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

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

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

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

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

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

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

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

### List of Useful R Packages

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

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

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

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

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

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

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

### mean Function in R (4 Examples)

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

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

### Median in R (5 Examples)

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

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

### Merge Time Series in R (Example)

### Merge Two Lists in R (Example)

### Mode in R (4 Programming Examples)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### quantile Function in R (6 Examples)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### sprintf R Function (6 Example Codes)

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

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

### Standard Error in R (2 Examples)

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

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

### str_count Function in R (stringr Package)

### str_detect Function in R (stringr Package)

### str_dup Function in R (stringr Package)

### str_extract Function in R (stringr Package)

### str_flatten Function in R (Example)

### str_length Function in R (Example)

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

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

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

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

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

### str_replace_na Function in R Programming (Example)

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

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

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

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

### str_trim Function in R (Example)

### str_trunc Function in R (Example)

### str_wrap Function in R (Example)

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

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

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

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

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

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

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

### sum Function in R (3 Examples)

### Suppress Warnings Globally in R (Example)

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

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

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

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

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

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

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

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

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

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

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

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

### The segments R Function | 3 Example Codes

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

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

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

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

### Unload Package without Restarting R (Example)

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

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

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

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

### Weighted Mean in R (5 Examples)

### Weighted Sum in R (Example)

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

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

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

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

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

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

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 |

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

**5**/

**5**(

**4**votes )

### Subscribe to my free statistics newsletter:

### R Tutorials

abs Function in R

all & any R Functions

Set Aspect Ratio of Plot

attach & detach R Functions

attr, attributes & structure in R

cbind R Command

Change ggplot2 Legend Title

Character to Numeric in R

Check if Object is Defined

col & row sums, means & medians

Complete Cases in R

Concatenate Vector of Strings

Convert Date to Weekday

cumsum R Function

Data Frame Column to Numeric

diff Command in R

difftime R Function

dim Function in R

dir R Function

Disable Scientific Notation

Draw Segments in R

droplevels R Example

Evaluate an Expression

Extract Characters from String

Factor to Numeric in R

Format Decimal Places

get, get0 & mget in R

is.na R Function

is.null Function in R

jitter R Function

Join Data with dplyr Package

length Function in R

lowess R Smoothing Function

max and min Functions in R

NA Omit in R

nchar R Function

ncol Function in R

nrow Function in R

outer Function in R

pairs & ggpairs Plot

parse, deparse & R expression

paste & paste0 Functions in R

pmax and pmin R Functions

polygon Plots in R

pretty R Function

R Find Missing Values

R Functions List (+ Examples)

R NA – Values

R Replace NA with 0

rbind & rbind.fill in R

Read Excel Files in R

readLines, n.readLines & readline

Remove Element from List

Remove Legend in ggplot2

Rename Column Name in R

Replace Last Comma of String

rev R Command

Round Numeric Data in R

Save & Load RData Workspace

scan R Function

setdiff R Function

setNames vs. setnames in R

sink Command in R

Sort, Order & Rank Data in R

sprintf Function in R

Square Root in R

str_c Function of stringr Package

str_sub Function of stringr Package

strptime & strftime Functions

substr & substring R Commands

sweep R Function

Transform Data Frames

union Function in R

unlist in R

weekdays, months, quarters & julian in R

with & within R Functions

Write Excel File in R