R FUNCTIONS

This is a list of some of the most popular R functions. Utilize the search bar to find any function and click on the card for usage and examples.
Some of these functions link to posts on ‘R CHARTS’, our site specialized in data visualization

graphics

abline()

Add straight lines to a plot

abline(a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL, coef = NULL, untf = FALSE, ...)

base

acos()

Arc-cosine function

acos(x)

dplyr

across()

Apply a function across multiple columns

across(.cols, .fns, ..., .names = NULL, .unpack = FALSE)

stats

addmargins()

Add margins on tables or arrays

addmargins(A, margin = seq_along(dim(A)), FUN = sum, quiet = FALSE)

base

aggregate()

Compute summary statistics for subsets of the data

aggregate(x, ...)

dplyr

all_of()

Select all columns based on a character vector

all_of(x)

dplyr

any_of()

Select columns based on a character vector, even if some do not exist

any_of(x, ..., vars = NULL)

base

apply()

Apply a function to the rows or columns of an array or matrix

apply(X, MARGIN, FUN, ..., simplify = TRUE)

utils

apropos()

Search for functions matching a character string or regular expression

apropos(what, where = FALSE, ignore.case = TRUE, dot_internals = FALSE, mode = "any")

dplyr

arrange()

Order the rows of a data frame based on the values of the selected columns

arrange(.data, ..., .by_group = FALSE)

base

as.numeric()

Coerce objects to numeric

as.numeric(x, ...)

base

asin()

Arc-sine function

asin(x)

base

atan()

Arc-tangent function

asin(x)

base

attach()

Access database objects by simply giving their names

attach(what, pos = 2L, name = deparse1(substitute(what), backtick = FALSE), warn.conflicts = TRUE)

graphics

axis()

Add axes to the a plot, allowing the specification of the side, colors, position, labels, ...

axis(side, at = NULL, labels = TRUE, tick = TRUE, line = NA, pos = NA, outer = FALSE, font = NA, lty = "solid", lwd = 1, lwd.ticks = lwd, col = NULL, col.ticks = NULL, hadj = NA, padj = NA, gap.axis = NA, ...)

graphics

barplot()

Create a vertical or horizontal bar plot

barplot(height, width = 1, space = NULL, names.arg = NULL, legend.text = NULL, beside = FALSE, horiz = FALSE, density = NULL, angle = 45, col = NULL, border = par("fg"), main = NULL, sub = NULL, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, xpd = TRUE, log = "", axes = TRUE, axisnames = TRUE, cex.axis = par("cex.axis"), cex.names = par("cex.axis"), inside = TRUE, plot = TRUE, axis.lty = 0, offset = 0, add = FALSE, ann = !add && par("ann"), args.legend = NULL, ...)

graphics

box()

Draw a box around a plot

box(which = "plot", lty = "solid", ...)

graphics

boxplot()

Draw a box and whisker plot of the data

boxplot(x, ..., range = 1.5, width = NULL, varwidth = FALSE, notch = FALSE, outline = TRUE, names, plot = TRUE, border = par("fg"), col = "lightgray", log = "", pars = list(boxwex = 0.8, staplewex = 0.5, outwex = 0.5), ann = !add, horizontal = FALSE, add = FALSE, at = NULL)

base

break

Break out of a loop

base

casefold()

Convert characters to uppercase or lowercase

casefold(x, upper = FALSE)

base

cat()

Concatenate and print

cat(... , file = "", sep = " ", fill = FALSE, labels = NULL, append = FALSE)

base

cbind()

Combine objects by columns

cbind(..., deparse.level = 1)

base

ceiling()

Round numbers to the smallest integer not less than the corresponding value

ceiling(x)

base

chartr()

Change one set of characters to another

chartr(old, new, x)

stats

chisq.test()

Pearson's Chi-squared independence, homogeneity and goodness-of-fit tests

chisq.test(x, y = NULL, correct = TRUE, p = rep(1/length(x), length(x)), rescale.p = FALSE, simulate.p.value = FALSE, B = 2000)

base

chol()

Cholesky decomposition of a matrix

chol(x, pivot = FALSE, LINPACK = FALSE, tol = -1, ...)

base

class()

Class of an object

class(x)

base

colMeans()

Column means

colMeans(x, na.rm = FALSE, dims = 1)

base

colSums()

Column sums

colSums(x, na.rm = FALSE, dims = 1)

dplyr

contains()

Select columns containing a string

contains(match, ignore.case = TRUE, vars = NULL)

graphics

contour()

Create a contour plot or add contour lines to a plot

contour(x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, length.out = ncol(z)), z, nlevels = 10, levels = pretty(zlim, nlevels), labels = NULL, xlim = range(x, finite = TRUE), ylim = range(y, finite = TRUE), zlim = range(z, finite = TRUE), labcex = 0.6, drawlabels = TRUE, method = "flattest", vfont, axes = TRUE, frame.plot = axes, col = par("fg"), lty = par("lty"), lwd = par("lwd"), add = FALSE, ...)

base

as.character()

Coerce objects to character

as.character(x, ...)

stats

cor()

Correlation and correlation matrix

cor(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman"))

base

cos()

Cosine function

cos(x)

stats

cov()

Covariance and covariance matrix

cov(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman"))

graphics

curve()

Draw functions on an interval

curve(expr, from = NULL, to = NULL, n = 101, add = FALSE, type = "l", xname = "x", xlab = xname, ylab = NULL, log = NULL, xlim = NULL, ...)

base

cut()

Categorize the values of a continuous variable in different levels of a factor

cut(x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ordered_result = FALSE, ...)

base

data.frame()

Create a data frame from the given list of variables of the same number of rows

data.frame(..., row.names = NULL, check.rows = FALSE, check.names = TRUE, fix.empty.names = TRUE, stringsAsFactors = FALSE)

utils

data()

Load specified datasets or list available

data(..., list = character(), package = NULL, lib.loc = NULL, verbose = getOption("verbose"), envir = .GlobalEnv, overwrite = TRUE)

base

date()

Character string with the current system date and time

stats

dbinom()

Density function for the binomial distribution

dbinom(x, size, prob, log = FALSE)

dplyr

desc()

Sort rows in descending order

desc(x)

base

detach()

Detach database from the search path

detach(name, pos = 2L, unload = FALSE, character.only = FALSE, force = FALSE)

base

det()

Determinant of a matrix

det(x, ...)

grDevices

dev.cur()

Number of current available graphics devices, including the null device

grDevices

dev.off()

Shut down the specified (current) graphics device

dev.off(which = dev.cur())

stats

dexp()

Density function for the exponential distribution

dexp(x, rate = 1, log = FALSE)

base

dim()

Get or set the dimensions of an object

dim(x)

base

dir()

List files in a directory

dir(path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

base

dir.create()

Create a folder inside a path

dir.create(path, showWarnings = TRUE, recursive = FALSE, mode = "0777")

stats

dnorm()

Density function for the normal distribution

dnorm(x, mean = 0, sd = 1, log = FALSE)

graphics

dotchart()

Create a Cleveland dot plot

dotchart(x, labels = NULL, groups = NULL, gdata = NULL, offset = 1/8, ann = par("ann"), xaxt = par("xaxt"), frame.plot = TRUE, log = "", cex = par("cex"), pt.cex = cex, pch = 21, gpch = 21, bg = par("bg"), color = par("fg"), gcolor = par("fg"), lcolor = "gray", xlim = range(x[is.finite(x)]), main = NULL, xlab = NULL, ylab = NULL, ...)

stats

dpois()

Density function for the Poisson distribution

dpois(x, lambda, log = FALSE)

stats

dunif()

Density function for the uniform distribution on the interval from min to max

dunif(x, min = 0, max = 1, log = FALSE)

base

eigen()

Eigenvalues and eigenvectors of a matrix

eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE)

dplyr

ends_with()

Selects columns ending with the given suffix (exact match)

ends_with(match, ignore.case = TRUE, vars = NULL)

dplyr

everything()

Select all columns

everything(vars = NULL)

base

exp()

Compute the exponential function

exp(x)

base

expm1()

Compute exp(x) - 1 accurately also for ∣x ∣≪ 1

expm1(x)

stats

var.test()

F test to compare two variances

var.test(x, y, ratio = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, ...)

base

factor()

Encode vectors as categorical data

factor(x = character(), levels, labels = levels, exclude = NA, ordered = is.ordered(x), nmax = NA)

base

file.copy()

Copy a file

file.copy(from, to, overwrite = recursive, recursive = FALSE, copy.mode = TRUE, copy.date = FALSE)

base

file.create()

Create a file

file.create(..., showWarnings = TRUE)

base

file.info()

Information about files

file.info(..., extra_cols = TRUE)

base

file.remove()

Remove a file

file.remove(...)

graphics

filled.contour()

Create a filled contour plot, also known as level plot

filled.contour(x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1, length.out = ncol(z)), z, xlim = range(x, finite = TRUE), ylim = range(y, finite = TRUE), zlim = range(z, finite = TRUE), levels = pretty(zlim, nlevels), nlevels = 20, color.palette = function(n) hcl.colors(n, "YlOrRd", rev = TRUE), col = color.palette(length(levels) - 1), plot.title, plot.axes, key.title, key.axes, asp = NA, xaxs = "i", yaxs = "i", las = 1, axes = TRUE, frame.plot = axes, ...)

dplyr

filter()

Subset the rows of a data frame based on specific conditions

filter(.data, ..., .by = NULL, .preserve = FALSE)

base

floor()

Round numbers to the largest integer not greater than the corresponding value

floor(x)

base

getRversion()

Get the numeric version of R running

base

getwd()

Returns an absolute filepath with the current working directory

getwd()

grDevices

graphics.off()

Shut down all open graphics devices

base

grep()

Pattern matching (returns the indices of the elements that yield a match)

grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, useBytes = FALSE, invert = FALSE)

base

grepl()

Pattern matching (returns a logical vector indicating if there was a match or not for each element)

grepl(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)

graphics

grid()

Add a grid to a plot

grid(nx = NULL, ny = nx, col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)

dplyr

group_by()

Group by one or several variables

group_by(.data, ..., .add = FALSE, .drop = group_by_drop_default(.data))

dplyr

group_cols()

Select the columns grouped with group_by

group_cols(vars = NULL, data = NULL)

base

gsub()

Replace all pattern matches

gsub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)

stats

hclust()

Compute a hierarchical cluster analysis on a set of dissimilarities

hclust(d, method = "complete", members = NULL)

utils

head()

First n rows/parts of an object

head(x, n = 6L, ...)

stats

heatmap()

Create heat maps with optional dendrograms

heatmap(x, Rowv = NULL, Colv = if (symm) "Rowv" else NULL, distfun = dist, hclustfun = hclust, reorderfun = function(d, w) reorder(d, w), add.expr, symm = FALSE, revC = identical(Colv, "Rowv"), scale = c("row", "column", "none"), na.rm = TRUE, margins = c(5, 5), ColSideColors, RowSideColors, cexRow = 0.2 + 1/log10(nr), cexCol = 0.2 + 1/log10(nc), labRow = NULL, labCol = NULL, main = NULL, xlab = NULL, ylab = NULL, keep.dendro = FALSE, verbose = getOption("verbose"), ...)

utils

help()

Obtain help of any function or package

help(topic, package = NULL, lib.loc = NULL, verbose = getOption("verbose"), try.all.packages = getOption("help.try.all.packages"), help_type = getOption("help_type"))

utils

help.search()

Search for help matching a character string

help.search(pattern, fields = c("alias", "concept", "title"), apropos, keyword, whatis, ignore.case = TRUE, package = NULL, lib.loc = NULL, help.db = getOption("help.db"), verbose = getOption("verbose"), rebuild = FALSE, agrep = NULL, use_UTF8 = FALSE, types = getOption("help.search.types"))

graphics

hist()

Create a histogram for the given data

hist(x, breaks = "Sturges", freq = NULL, probability = !freq, include.lowest = TRUE, right = TRUE, fuzz = 1e-7, density = NULL, angle = 45, col = "lightgray", border = NULL, main = paste("Histogram of" , xname), xlim = range(breaks), ylim = NULL, xlab = xname, ylab, axes = TRUE, plot = TRUE, labels = FALSE, nclass = NULL, warn.unused = TRUE, ...)

utils

history()

Display the commands history

history(max.show = 25, reverse = FALSE, pattern, ...)

base

ifelse()

Conditional element selection

ifelse(test, yes, no)

graphics

image()

Display spatial data, creating a grid of rectangles colored based on the values of 'z'

image(x, y, z, zlim, xlim, ylim, col = hcl.colors(12, "YlOrRd", rev = TRUE), add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab, breaks, oldstyle = FALSE, useRaster, ...)

utils

install.packages()

Download and install R packages from CRAN or from local files

install.packages(pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, type), method, available = NULL, destdir = NULL, dependencies = NA, type = getOption("pkgType"), configure.args = getOption("configure.args"), configure.vars = getOption("configure.vars"), clean = FALSE, Ncpus = getOption("Ncpus", 1L), verbose = getOption("verbose"), libs_only = FALSE, INSTALL_opts, quiet = FALSE, keep_outputs = FALSE, ...)

stats

IQR()

Interquartile range

IQR(x, na.rm = FALSE, type = 7)

base

is.atomic()

Check if an object is atomic

is.atomic(x)

base

is.character()

Check if an object is character

is.character(x)

base

is.complex()

Check if an object is of complex type

is.complex(x)

base

is.double()

Check if an object is of double type

is.double(x)

base

is.integer()

Check if an object is of integer type

is.integer(x)

base

is.logical()

Check if an object is of logical type

is.logical(x)

base

is.numeric()

Check if an object is numeric

is.numeric(x)

base

is.raw()

Check if an object is of raw type

is.raw(x)

stats

ks.test()

One and two sample Kolmogorov-Smirnov tests

ks.test(x, y, ...,alternative = c("two.sided", "less", "greater"), exact = NULL, simulate.p.value = FALSE, B = 2000)

stats

kruskal.test()

Kruskal-Wallis rank sum test to compare k medians

kruskal.test(x, ...)

dplyr

last_col()

Select the last column

last_col(offset = 0L, vars = NULL)

graphics

legend()

Add a legend to a plot

legend(x, y = NULL, legend, fill = NULL, col = par("col"), border = "black", lty, lwd, pch, angle = 45, density = NULL, bty = "o", bg = par("bg"), box.lwd = par("lwd"), box.lty = par("lty"), box.col = par("fg"), pt.bg = NA, cex = 1, pt.cex = cex, pt.lwd = lwd, xjust = 0, yjust = 1, x.intersp = 1, y.intersp = 1, adj = c(0, 0.5), text.width = NULL, text.col = par("col"), text.font = NULL, merge = do.lines && has.pch, trace = FALSE, plot = TRUE, ncol = 1, horiz = FALSE, title = NULL, inset = 0, xpd, title.col = text.col[1], title.adj = 0.5, title.cex = cex[1], title.font = text.font[1], seg.len = 2)

base

length()

Get or set the length of objects

length(x)

base

lengths()

Get the length of each element of a list or atomic vector

lengths(x, use.names = TRUE)

base

list()

Create a list from a set of objects

list(...)

base

list.files()

List files in a directory

list.files(path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)

base

load()

Load a workspace

load(file, envir = parent.frame(), verbose = FALSE)

base

log()

Compute logarithms (natural logarithms by default)

log(x, base = exp(1))

base

log10()

Compute base 10 logarithms

log10(x)

base

log1p()

Compute log(1 + x) accurately also for ∣x ∣≪ 1

log1p(x)

base

log2()

Compute base 2 logarithms

log2(x)

base

ls()

List workspace objects

ls(name, pos = -1L, envir = as.environment(pos), all.names = FALSE, pattern, sorted = TRUE)

dplyr

matches()

Select columns that match a regular expression

matches(match, ignore.case = TRUE, perl = FALSE, vars = NULL)

graphics

matlines()

Add more lines to a matplot

matlines(x, y, type = "l", lty = 1:5, lwd = 1, pch = NULL, col = 1:6, ...)

graphics

matplot()

Plot all the columns of a matrix at the same time

matplot(x, y, type = "p", lty = 1:5, lwd = 1, lend = par("lend"), pch = NULL, col = 1:6, cex = NULL, bg = NA, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, log = "", ..., add = FALSE, verbose = getOption("verbose"))

base

crossprod()

Matrix crossproduct (t(A) %*% B)

crossprod(x, y = NULL)

base

diag()

Extract, replace or construct a diagonal matrix

diag(x = 1, nrow, ncol, names = TRUE)

base

matrix()

Create a matrix from a given set of values

matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)

base

max()

Return the maximum of the input values

max(..., na.rm = FALSE)

base

mean()

Calculate the arithmetic mean

mean(x, trim = 0, na.rm = FALSE, ...)

stats

mad()

Median absolute deviation

mad(x, center = median(x), constant = 1.4826, na.rm = FALSE, low = FALSE, high = FALSE)

stats

median()

Calculate the sample median

median(x, na.rm = FALSE, ...)

base

merge()

Merge two data frames by column or row names, or perform different database (SQL) joins

merge(x, y, ...)

base

message()

Diagnostic messages

message(..., domain = NULL, appendLF = TRUE)

base

min()

Return the minimum of the input values

min(..., na.rm = FALSE)

base

mode()

Mode of an object (Do not confuse with the statistical mode)

mode(x)

graphics

mtext()

Add text to the margins of a plot

mtext(text, side = 3, line = 0, outer = FALSE, at = NA, adj = NA, padj = NA, cex = NA, col = NA, font = NA, ...)

dplyr

mutate()

Create, add or modify columns of a data frame

mutate(.data, ..., .by = NULL, .keep = c("all", "used", "unused", "none"), .before = NULL, .after = NULL)

base

nchar()

Count the number of characters

nchar(x, type = "chars", allowNA = FALSE, keepNA = NA)

base

ncol()

Get the number of columns

ncol(x)

base

next

Halt the processing of the current iteration and advance the looping index

base

noquote()

Print character strings without quotes

noquote(obj, right = FALSE)

base

nrow()

Get the number of rows

nrow(x)

dplyr

num_range()

Select columns with a prefix and numeric range in their names

num_range(prefix, range, suffix = "", width = NULL, vars = NULL)

base

nzchar()

Check if elements of a character vector are empty or not

nzchar(x, keepNA = FALSE)

utils

old.packages()

Check for not up-to-date R packages

old.packages(lib.loc = NULL, repos = getOption("repos"), contriburl = contrib.url(repos, type), instPkgs = installed.packages(lib.loc = lib.loc, ...), method, available = NULL, checkBuilt = FALSE, ..., type = getOption("pkgType"))

base

order()

Returns a permutation of the order of the elements of a vector

order(..., na.last = TRUE, decreasing = FALSE, method = c("auto", "shell", "radix"))

base

outer()

Outer product

outer(X, Y, FUN = "*", ...)

graphics

pairs()

Create a matrix scatter plot

pairs(x, labels, panel = points, ..., horInd = 1:nc, verInd = 1:nc, lower.panel = panel, upper.panel = panel, diag.panel = NULL, text.panel = textPanel, label.pos = 0.5 + has.diag/3, line.main = 3, cex.labels = NULL, font.labels = 1, row1attop = TRUE, gap = 1, log = "", horOdd = !row1attop, verOdd = !row1attop)

base

paste()

Concatenate strings with an empty string as separator by default

paste(..., sep = " ", collapse = NULL, recycle0 = FALSE)

base

paste0()

Concatenate strings without separation

paste0(..., collapse = NULL, recycle0 = FALSE)

stats

pbinom()

Distribution function for the binomial distribution

pbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)

stats

pexp()

Distribution function for the exponential distribution

pexp(q, rate = 1, lower.tail = TRUE, log.p = FALSE)

graphics

pie()

Create a pie chart

pie(x, labels = names(x), edges = 200, radius = 0.8, clockwise = FALSE, init.angle = if(clockwise) 90 else 0, density = NULL, angle = 45, col = NULL, border = NULL, lty = NULL, main = NULL, ...)

graphics

plot()

Generic function for plotting objects

plot(x, y, ...)

base

pmax()

Return the maximum values in parallel for different vectors

pmax(..., na.rm = FALSE)

base

pmin()

Return the minimum values in parallel for different vectors

pmin(..., na.rm = FALSE)

stats

pnorm()

Distribution function for the normal distribution

pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)

stats

ppois()

Distribution function for the Poisson distribution

ppois(q, lambda, lower.tail = TRUE, log.p = FALSE)

base

print()

Print values

print(x, ...)

base

prop.table()

Create a joint relative frequency table

prop.table(x, margin = NULL)

stats

punif()

Distribution function for the uniform distribution on the interval from min to max

punif(q, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)

stats

qbinom()

Quantile function for the binomial distribution

qbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE)

stats

qexp()

Quantile function for the exponential distribution

qexp(p, rate = 1, lower.tail = TRUE, log.p = FALSE)

stats

qnorm()

Quantile function for the normal distribution

qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)

stats

qpois()

Quantile function for the Poisson distribution

qpois(p, lambda, lower.tail = TRUE, log.p = FALSE)

base

qr()

QR decomposition of a matrix

qr(x, ...)

stats

quantile()

Sample quantiles corresponding to the given probabilities

quantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type = 7, digits = 7, ...)

grDevices

quartz()

Open a macOS Quartz graphic device

quartz(title, width, height, pointsize, family, antialias, type, file = NULL, bg, canvas, dpi)

stats

qunif()

Quantile function for the uniform distribution on the interval from min to max

qunif(p, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)

base

R.Version()

Get the version of R running

base

sample()

Random samples and permutations

sample(x, size, replace = FALSE, prob = NULL)

base

range()

Range of values, this is, it returns a two-element vector with the minimum and maximum values of the data

range(..., na.rm = FALSE, finite = FALSE)

base

rbind()

Combine objects by rows

rbind(..., deparse.level = 1)

stats

rbinom()

Random generation for the binomial distribution

rbinom(n, size, prob)

utils

read.table()

Read a TXT file

read.table(file, header = FALSE, sep = "", quote = "\"'", dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"), row.names, col.names, as.is = !stringsAsFactors, tryLogical = TRUE, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, comment.char = "#", allowEscapes = FALSE, flush = FALSE, stringsAsFactors = FALSE, fileEncoding = "", encoding = "unknown", text, skipNul = FALSE)

utils

read.csv()

Read a CSV file separated by commas

read.csv(file, header = TRUE, sep = ",", quote = "\"", dec = ".", fill = TRUE, comment.char = "", ...)

utils

read.csv2()

Read a CSV file separated by semicolon

read.csv2(file, header = TRUE, sep = ";", quote = "\"", dec = ",", fill = TRUE, comment.char = "", ...)

base

readRDS()

Load an RDS file

readRDS(file, refhook = NULL)

dplyr

rename_with()

Change the names of individual columns of a data frame using a function

rename_with(.data, .fn, .cols = everything(), ...)

dplyr

rename()

Change the names of individual columns of a data frame

rename(.data, ...)

base

rep()

Replicate elements of vectors and lists

rep(x, times, length.out, each)

stats

rexp()

Random generation for the exponential distribution

rexp(n, rate = 1)

base

rm()

Remove objects from an environment

rm(..., list = character(), pos = -1, envir = as.environment(pos), inherits = FALSE)

stats

rnorm()

Random generation for the normal distribution

rnorm(n, mean = 0, sd = 1)

base

round()

Round numbers to the specified number of decimal places (0 by default)

round(x, digits = 0)

base

rowMeans()

Row means

rowMeans(x, na.rm = FALSE, dims = 1)

base

rowSums()

Row sums

rowSums(x, na.rm = FALSE, dims = 1)

stats

rpois()

Random generation for the Poisson distribution

rpois(n, lambda)

stats

runif()

Random generation for the uniform distribution on the interval from min to max

runif(n, min = 0, max = 1)

base

sapply()

Apply a function to a vector or list and return a vector, a matrix or an array

sapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)

base

save()

Save R objects

save(..., list = character(), file = stop("'file' must be specified"), ascii = FALSE, version = NULL, envir = parent.frame(), compress = isTRUE(!ascii), compression_level, eval.promises = TRUE, precheck = TRUE)

base

save.image()

Save the current workspace

save.image(file = ".RData", version = NULL, ascii = FALSE, compress = !ascii, safe = TRUE)

base

saveRDS()

Save a single R object

saveRDS(object, file = "", ascii = FALSE, version = NULL, compress = TRUE, refhook = NULL)

stats

sd()

Compute the standard deviation of a vector

sd(x, na.rm = FALSE)

graphics

segments()

Add segments to a plot

segments(x0, y0, x1 = x0, y1 = y0, col = par("fg"), lty = par("lty"), lwd = par("lwd"), ...)

dplyr

select()

Select (and optionally rename) variables in a data frame

select(.data, ...)

base

seq()

Generate sequences

seq(from = 1, to = 1, by = ((to - from)/(length.out - 1)), length.out = NULL, along.with = NULL, ...)

base

set.seed()

Specify a seed for random number generation

set.seed(seed, kind = NULL, normal.kind = NULL, sample.kind = NULL)

utils

setTxtProgressBar()

Update a text progress bar

setTxtProgressBar(pb, value, title = NULL, label = NULL)

base

setwd()

Set the working directory

setwd(dir)

utils

setWinProgressBar()

Update windows progress bar widget

setWinProgressBar(pb, value, title = NULL, label = NULL)

stats

shapiro.test()

Shapiro-Wilk test of normality

shapiro.test(x)

base

signif()

Round the values to the specified number of significant digits (6 by default)

signif(x, digits = 6)

base

sin()

Sine function

sin(x)

base

svd()

Singular value decomposition of a rectangular matrix

svd(x, nu = min(n, p), nv = min(n, p), LINPACK = FALSE)

dplyr

slice_head()

Select the first row/s

slice_head(.data, ..., n, prop, by = NULL)

dplyr

slice_sample()

Select a random sample of rows

slice_sample(.data, ..., n, prop, by = NULL, weight_by = NULL, replace = FALSE)

dplyr

slice_tail()

Select the last row/s

slice_tail(.data, ..., n, prop, by = NULL)

dplyr

slice()

Filter rows based on its index/position

slice(.data, ..., .by = NULL, .preserve = FALSE)

graphics

smoothScatter()

Create a smooth color kernel density estimation of a scatter plot

smoothScatter(x, y = NULL, nbin = 128, bandwidth, colramp = colorRampPalette(c("white", blues9)), nrpoints = 100, ret.selection = FALSE, pch = ".", cex = 1, col = "black", transformation = function(x) x^.25, postPlotHook = box, xlab = NULL, ylab = NULL, xlim, ylim, xaxs = par("xaxs"), yaxs = par("yaxs"), ...)

base

sort()

Sorts data in increasing or decreasing order

sort(x, decreasing = FALSE, ...)

graphics

spineplot()

Create spine plots and spinograms

spineplot(x, y = NULL, breaks = NULL, tol.ylab = 0.05, off = NULL, ylevels = NULL, col = NULL, main = "", xlab = NULL, ylab = NULL, xaxlabels = NULL, yaxlabels = NULL, xlim = NULL, ylim = c(0, 1), axes = TRUE, weights = NULL, ...)

base

split()

Divide the input data x into the groups defined by f

split(x, f, drop = FALSE, ...)

base

sprintf()

Print formatted strings

sprintf(fmt, ...)

base

sqrt()

Square root

sqrt(x)

dplyr

starts_with()

Select columns starting with the given prefix (exact match)

starts_with(match, ignore.case = TRUE, vars = NULL)

graphics

stem()

Create a stem and leaf plot

stem(x, scale = 1, width = 80, atom = 1e-08)

base

stop()

Stops the execution of the current expression and displays an error message

stop(..., call. = TRUE, domain = NULL)

base

storage.mode()

Storage mode of an object

storage.mode(x)

utils

str()

Structure of an object

str(object, ...)

graphics

stripchart()

Create one dimensional scatter plots

stripchart(x, method = "overplot", jitter = 0.1, offset = 1/3, vertical = FALSE, group.names, add = FALSE, at = NULL, xlim = NULL, ylim = NULL, ylab = NULL, xlab = NULL, dlab = "", glab = "", log = "", pch = 0, col = par("fg"), cex = par("cex"), axes = TRUE, frame.plot = axes, ...)

base

strsplit()

Split a string into substrings based on a delimiter

strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE)

base

sub()

Replace the first pattern match

sub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)

base

subset()

Subset vectors, matrices or data frames based on conditions

subset(x, ...)

base

substr()

Extract or replace substrings of a character vector

substr(x, start, stop)

base

substring()

Extract or replace substrings of a character vector

substring(text, first, last = 1000000L)

dplyr

summarise()

Aggregates (along with group_by) and summarizes data creating a new data frame with the specified summary statistics

summarise(.data, ..., .by = NULL, .groups = NULL)

base

switch()

Evaluates an expression and chooses an option from a list of alternatives

switch(EXPR, ...)

base

Sys.Date()

Current date

base

Sys.sleep()

Suspend execution of R expressions for a specified time interval

Sys.sleep(time)

base

Sys.time()

Current date and time

stats

t.test()

One and two sample t-tests to compare means

t.test(x, y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, ...)

base

table()

Create a contingency table of the counts at each combination of factor levels

table(..., exclude = if (useNA == "no") c(NA, NaN), useNA = c("no", "ifany", "always"), dnn = list.names(...), deparse.level = 1)

utils

tail()

Last n rows/parts of an object

tail(x, n = 6L, keepnums = FALSE, addrownums, ...)

base

tan()

Tangent function

tan(x)

base

tapply()

Create group summaries based on factor levels

tapply(X, INDEX, FUN = NULL, ..., default = NA, simplify = TRUE)

stats

prop.test()

Test of equal or given proportions

prop.test(x, n, p = NULL, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = TRUE)

graphics

text()

Add text to a plot

text(x, y = NULL, labels = seq_along(x$x), adj = NULL, pos = NULL, offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL, ...)

graphics

title()

Add a title to a plot

title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL, line = NA, outer = FALSE, ...)

base

tolower()

Convert characters to lowercase

tolower(x)

base

toupper()

Convert characters to uppercase

toupper(x)

base

t()

Transpose of a matrix

t(x)

base

trimws()

Remove leading and/or trailing whitespaces

trimws(x, which = c("both", "left", "right"), whitespace = "[ \t\r\n]")

base

trunc()

Round values removing their decimal places

trunc(x, ...)

base

tryCatch()

Error and warning handling

tryCatch(expr, ..., finally)

utils

txtProgressBar()

Text progress bar

txtProgressBar(min = 0, max = 1, initial = 0, char = "=", width = NA, title, label, style = 1, file = "")

base

typeof()

Type of an object

typeof(x)

base

unlink()

Delete files and directories

unlink(x, recursive = FALSE, force = FALSE, expand = TRUE)

utils

update.packages()

Update R packages

update.packages(lib.loc = NULL, repos = getOption("repos"), contriburl = contrib.url(repos, type), method, instlib = NULL, ask = TRUE, available = NULL, oldPkgs = NULL, ..., checkBuilt = FALSE, type = getOption("pkgType"))

stats

var()

Compute the variance of a vector

var(x, y = NULL, na.rm = FALSE, use)

base

c()

Concatenate data of the same type

c(...)

base

warning()

Warning messages

warning(..., call. = TRUE, immediate. = FALSE, noBreaks. = FALSE, domain = NULL)

base

warnings()

Print last warning message

warnings(...)

stats

weighted.mean()

Weighted arithmetic mean

weighted.mean(x, w, ..., na.rm = FALSE)

dplyr

where()

Select columns for which a function returns TRUE

where(fn)

stats

wilcox.test()

Wilcoxon signed rank and rank sum (Mann-Whitney U) tests

wilcox.test(x, y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, exact = NULL, correct = TRUE, conf.int = FALSE, conf.level = 0.95, tol.root = 1e-4, digits.rank = Inf, ...)

grDevices

windows()

Open a Windows graphic device

windows(width, height, pointsize, record, rescale, xpinch, ypinch, bg, canvas, gamma, xpos, ypos, buffered, title, restoreConsole, clickToConfirm, fillOddEven, family, antialias)

utils

winProgressBar()

Windows progress bar widget

winProgressBar(title = "R progress bar", label = "", min = 0, max = 1, initial = 0, width = 300)

utils

write.csv()

Export as CSV with comma as separator

write.csv(x, file = "", append = FALSE, quote = TRUE, sep = ",", eol = "\n", na = "NA", dec = ".", row.names = TRUE, col.names = TRUE, qmethod = c("escape", "double"), fileEncoding = "")

utils

write.csv2()

Export as CSV with semicolon as separator

write.csv2(x, file = "", append = FALSE, quote = TRUE, sep = ";", eol = "\n", na = "NA", dec = ",", row.names = TRUE, col.names = TRUE, qmethod = c("escape", "double"), fileEncoding = "")

utils

write.table()

Export as TXT file

write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ", eol = "\n", na = "NA", dec = ".", row.names = TRUE, col.names = TRUE, qmethod = c("escape", "double"), fileEncoding = "")

grDevices

X11()

Open a X11 graphic device

X11(display = "", width, height, pointsize, gamma, bg, canvas, fonts, family, xpos, ypos, title, type, antialias, symbolfamily)