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
abline()
Add straight lines to a plot
abline(a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL, coef = NULL, untf = FALSE, ...)
acos()
Arc-cosine function
acos(x)
across()
Apply a function across multiple columns
across(.cols, .fns, ..., .names = NULL, .unpack = FALSE)
addmargins()
Add margins on tables or arrays
addmargins(A, margin = seq_along(dim(A)), FUN = sum, quiet = FALSE)
aggregate()
Compute summary statistics for subsets of the data
aggregate(x, ...)
all_of()
Select all columns based on a character vector
all_of(x)
any_of()
Select columns based on a character vector, even if some do not exist
any_of(x, ..., vars = NULL)
apply()
Apply a function to the rows or columns of an array or matrix
apply(X, MARGIN, FUN, ..., simplify = TRUE)
apropos()
Search for functions matching a character string or regular expression
apropos(what, where = FALSE, ignore.case = TRUE, dot_internals = FALSE, mode = "any")
arrange()
Order the rows of a data frame based on the values of the selected columns
arrange(.data, ..., .by_group = FALSE)
as.numeric()
Coerce objects to numeric
as.numeric(x, ...)
asin()
Arc-sine function
asin(x)
atan()
Arc-tangent function
asin(x)
attach()
Access database objects by simply giving their names
attach(what, pos = 2L, name = deparse1(substitute(what), backtick = FALSE), warn.conflicts = TRUE)
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, ...)
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, ...)
box()
Draw a box around a plot
box(which = "plot", lty = "solid", ...)
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)
break
Break out of a loop
casefold()
Convert characters to uppercase or lowercase
casefold(x, upper = FALSE)
cat()
Concatenate and print
cat(... , file = "", sep = " ", fill = FALSE, labels = NULL, append = FALSE)
cbind()
Combine objects by columns
cbind(..., deparse.level = 1)
ceiling()
Round numbers to the smallest integer not less than the corresponding value
ceiling(x)
chartr()
Change one set of characters to another
chartr(old, new, x)
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)
chol()
Cholesky decomposition of a matrix
chol(x, pivot = FALSE, LINPACK = FALSE, tol = -1, ...)
class()
Class of an object
class(x)
colMeans()
Column means
colMeans(x, na.rm = FALSE, dims = 1)
colSums()
Column sums
colSums(x, na.rm = FALSE, dims = 1)
contains()
Select columns containing a string
contains(match, ignore.case = TRUE, vars = NULL)
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, ...)
as.character()
Coerce objects to character
as.character(x, ...)
cor()
Correlation and correlation matrix
cor(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman"))
cos()
Cosine function
cos(x)
cov()
Covariance and covariance matrix
cov(x, y = NULL, use = "everything", method = c("pearson", "kendall", "spearman"))
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, ...)
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, ...)
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)
data()
Load specified datasets or list available
data(..., list = character(), package = NULL, lib.loc = NULL, verbose = getOption("verbose"), envir = .GlobalEnv, overwrite = TRUE)
date()
Character string with the current system date and time
dbinom()
Density function for the binomial distribution
dbinom(x, size, prob, log = FALSE)
desc()
Sort rows in descending order
desc(x)
detach()
Detach database from the search path
detach(name, pos = 2L, unload = FALSE, character.only = FALSE, force = FALSE)
det()
Determinant of a matrix
det(x, ...)
dev.cur()
Number of current available graphics devices, including the null device
dev.off()
Shut down the specified (current) graphics device
dev.off(which = dev.cur())
dexp()
Density function for the exponential distribution
dexp(x, rate = 1, log = FALSE)
dim()
Get or set the dimensions of an object
dim(x)
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)
dir.create()
Create a folder inside a path
dir.create(path, showWarnings = TRUE, recursive = FALSE, mode = "0777")
dnorm()
Density function for the normal distribution
dnorm(x, mean = 0, sd = 1, log = FALSE)
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, ...)
dpois()
Density function for the Poisson distribution
dpois(x, lambda, log = FALSE)
dunif()
Density function for the uniform distribution on the interval from min to max
dunif(x, min = 0, max = 1, log = FALSE)
eigen()
Eigenvalues and eigenvectors of a matrix
eigen(x, symmetric, only.values = FALSE, EISPACK = FALSE)
ends_with()
Selects columns ending with the given suffix (exact match)
ends_with(match, ignore.case = TRUE, vars = NULL)
everything()
Select all columns
everything(vars = NULL)
exp()
Compute the exponential function
exp(x)
expm1()
Compute exp(x) - 1 accurately also for ∣x ∣≪ 1
expm1(x)
var.test()
F test to compare two variances
var.test(x, y, ratio = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, ...)
factor()
Encode vectors as categorical data
factor(x = character(), levels, labels = levels, exclude = NA, ordered = is.ordered(x), nmax = NA)
file.copy()
Copy a file
file.copy(from, to, overwrite = recursive, recursive = FALSE, copy.mode = TRUE, copy.date = FALSE)
file.create()
Create a file
file.create(..., showWarnings = TRUE)
file.info()
Information about files
file.info(..., extra_cols = TRUE)
file.remove()
Remove a file
file.remove(...)
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, ...)
filter()
Subset the rows of a data frame based on specific conditions
filter(.data, ..., .by = NULL, .preserve = FALSE)
floor()
Round numbers to the largest integer not greater than the corresponding value
floor(x)
getRversion()
Get the numeric version of R running
getwd()
Returns an absolute filepath with the current working directory
getwd()
graphics.off()
Shut down all open graphics devices
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)
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)
grid()
Add a grid to a plot
grid(nx = NULL, ny = nx, col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)
group_by()
Group by one or several variables
group_by(.data, ..., .add = FALSE, .drop = group_by_drop_default(.data))
group_cols()
Select the columns grouped with group_by
group_cols(vars = NULL, data = NULL)
gsub()
Replace all pattern matches
gsub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)
hclust()
Compute a hierarchical cluster analysis on a set of dissimilarities
hclust(d, method = "complete", members = NULL)
head()
First n rows/parts of an object
head(x, n = 6L, ...)
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"), ...)
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"))
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"))
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, ...)
history()
Display the commands history
history(max.show = 25, reverse = FALSE, pattern, ...)
ifelse()
Conditional element selection
ifelse(test, yes, no)
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, ...)
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, ...)
IQR()
Interquartile range
IQR(x, na.rm = FALSE, type = 7)
is.atomic()
Check if an object is atomic
is.atomic(x)
is.character()
Check if an object is character
is.character(x)
is.complex()
Check if an object is of complex type
is.complex(x)
is.double()
Check if an object is of double type
is.double(x)
is.integer()
Check if an object is of integer type
is.integer(x)
is.logical()
Check if an object is of logical type
is.logical(x)
is.numeric()
Check if an object is numeric
is.numeric(x)
is.raw()
Check if an object is of raw type
is.raw(x)
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)
kruskal.test()
Kruskal-Wallis rank sum test to compare k medians
kruskal.test(x, ...)
last_col()
Select the last column
last_col(offset = 0L, vars = NULL)
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)
length()
Get or set the length of objects
length(x)
lengths()
Get the length of each element of a list or atomic vector
lengths(x, use.names = TRUE)
list()
Create a list from a set of objects
list(...)
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)
load()
Load a workspace
load(file, envir = parent.frame(), verbose = FALSE)
log()
Compute logarithms (natural logarithms by default)
log(x, base = exp(1))
log10()
Compute base 10 logarithms
log10(x)
log1p()
Compute log(1 + x) accurately also for ∣x ∣≪ 1
log1p(x)
log2()
Compute base 2 logarithms
log2(x)
ls()
List workspace objects
ls(name, pos = -1L, envir = as.environment(pos), all.names = FALSE, pattern, sorted = TRUE)
matches()
Select columns that match a regular expression
matches(match, ignore.case = TRUE, perl = FALSE, vars = NULL)
matlines()
Add more lines to a matplot
matlines(x, y, type = "l", lty = 1:5, lwd = 1, pch = NULL, col = 1:6, ...)
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"))
crossprod()
Matrix crossproduct (t(A) %*% B)
crossprod(x, y = NULL)
diag()
Extract, replace or construct a diagonal matrix
diag(x = 1, nrow, ncol, names = TRUE)
matrix()
Create a matrix from a given set of values
matrix(data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
max()
Return the maximum of the input values
max(..., na.rm = FALSE)
mean()
Calculate the arithmetic mean
mean(x, trim = 0, na.rm = FALSE, ...)
mad()
Median absolute deviation
mad(x, center = median(x), constant = 1.4826, na.rm = FALSE, low = FALSE, high = FALSE)
median()
Calculate the sample median
median(x, na.rm = FALSE, ...)
merge()
Merge two data frames by column or row names, or perform different database (SQL) joins
merge(x, y, ...)
message()
Diagnostic messages
message(..., domain = NULL, appendLF = TRUE)
min()
Return the minimum of the input values
min(..., na.rm = FALSE)
mode()
Mode of an object (Do not confuse with the statistical mode)
mode(x)
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, ...)
mutate()
Create, add or modify columns of a data frame
mutate(.data, ..., .by = NULL, .keep = c("all", "used", "unused", "none"), .before = NULL, .after = NULL)
nchar()
Count the number of characters
nchar(x, type = "chars", allowNA = FALSE, keepNA = NA)
ncol()
Get the number of columns
ncol(x)
next
Halt the processing of the current iteration and advance the looping index
noquote()
Print character strings without quotes
noquote(obj, right = FALSE)
nrow()
Get the number of rows
nrow(x)
num_range()
Select columns with a prefix and numeric range in their names
num_range(prefix, range, suffix = "", width = NULL, vars = NULL)
nzchar()
Check if elements of a character vector are empty or not
nzchar(x, keepNA = FALSE)
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"))
order()
Returns a permutation of the order of the elements of a vector
order(..., na.last = TRUE, decreasing = FALSE, method = c("auto", "shell", "radix"))
outer()
Outer product
outer(X, Y, FUN = "*", ...)
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)
paste()
Concatenate strings with an empty string as separator by default
paste(..., sep = " ", collapse = NULL, recycle0 = FALSE)
paste0()
Concatenate strings without separation
paste0(..., collapse = NULL, recycle0 = FALSE)
pbinom()
Distribution function for the binomial distribution
pbinom(q, size, prob, lower.tail = TRUE, log.p = FALSE)
pexp()
Distribution function for the exponential distribution
pexp(q, rate = 1, lower.tail = TRUE, log.p = FALSE)
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, ...)
plot()
Generic function for plotting objects
plot(x, y, ...)
pmax()
Return the maximum values in parallel for different vectors
pmax(..., na.rm = FALSE)
pmin()
Return the minimum values in parallel for different vectors
pmin(..., na.rm = FALSE)
pnorm()
Distribution function for the normal distribution
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
ppois()
Distribution function for the Poisson distribution
ppois(q, lambda, lower.tail = TRUE, log.p = FALSE)
print()
Print values
print(x, ...)
prop.table()
Create a joint relative frequency table
prop.table(x, margin = NULL)
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)
qbinom()
Quantile function for the binomial distribution
qbinom(p, size, prob, lower.tail = TRUE, log.p = FALSE)
qexp()
Quantile function for the exponential distribution
qexp(p, rate = 1, lower.tail = TRUE, log.p = FALSE)
qnorm()
Quantile function for the normal distribution
qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
qpois()
Quantile function for the Poisson distribution
qpois(p, lambda, lower.tail = TRUE, log.p = FALSE)
qr()
QR decomposition of a matrix
qr(x, ...)
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, ...)
quartz()
Open a macOS Quartz graphic device
quartz(title, width, height, pointsize, family, antialias, type, file = NULL, bg, canvas, dpi)
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)
R.Version()
Get the version of R running
sample()
Random samples and permutations
sample(x, size, replace = FALSE, prob = NULL)
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)
rbind()
Combine objects by rows
rbind(..., deparse.level = 1)
rbinom()
Random generation for the binomial distribution
rbinom(n, size, prob)
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)
read.csv()
Read a CSV file separated by commas
read.csv(file, header = TRUE, sep = ",", quote = "\"", dec = ".", fill = TRUE, comment.char = "", ...)
read.csv2()
Read a CSV file separated by semicolon
read.csv2(file, header = TRUE, sep = ";", quote = "\"", dec = ",", fill = TRUE, comment.char = "", ...)
readRDS()
Load an RDS file
readRDS(file, refhook = NULL)
rename_with()
Change the names of individual columns of a data frame using a function
rename_with(.data, .fn, .cols = everything(), ...)
rename()
Change the names of individual columns of a data frame
rename(.data, ...)
rep()
Replicate elements of vectors and lists
rep(x, times, length.out, each)
rexp()
Random generation for the exponential distribution
rexp(n, rate = 1)
rm()
Remove objects from an environment
rm(..., list = character(), pos = -1, envir = as.environment(pos), inherits = FALSE)
rnorm()
Random generation for the normal distribution
rnorm(n, mean = 0, sd = 1)
round()
Round numbers to the specified number of decimal places (0 by default)
round(x, digits = 0)
rowMeans()
Row means
rowMeans(x, na.rm = FALSE, dims = 1)
rowSums()
Row sums
rowSums(x, na.rm = FALSE, dims = 1)
rpois()
Random generation for the Poisson distribution
rpois(n, lambda)
runif()
Random generation for the uniform distribution on the interval from min to max
runif(n, min = 0, max = 1)
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)
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)
save.image()
Save the current workspace
save.image(file = ".RData", version = NULL, ascii = FALSE, compress = !ascii, safe = TRUE)
saveRDS()
Save a single R object
saveRDS(object, file = "", ascii = FALSE, version = NULL, compress = TRUE, refhook = NULL)
sd()
Compute the standard deviation of a vector
sd(x, na.rm = FALSE)
segments()
Add segments to a plot
segments(x0, y0, x1 = x0, y1 = y0, col = par("fg"), lty = par("lty"), lwd = par("lwd"), ...)
select()
Select (and optionally rename) variables in a data frame
select(.data, ...)
seq()
Generate sequences
seq(from = 1, to = 1, by = ((to - from)/(length.out - 1)), length.out = NULL, along.with = NULL, ...)
set.seed()
Specify a seed for random number generation
set.seed(seed, kind = NULL, normal.kind = NULL, sample.kind = NULL)
setTxtProgressBar()
Update a text progress bar
setTxtProgressBar(pb, value, title = NULL, label = NULL)
setwd()
Set the working directory
setwd(dir)
setWinProgressBar()
Update windows progress bar widget
setWinProgressBar(pb, value, title = NULL, label = NULL)
shapiro.test()
Shapiro-Wilk test of normality
shapiro.test(x)
signif()
Round the values to the specified number of significant digits (6 by default)
signif(x, digits = 6)
sin()
Sine function
sin(x)
svd()
Singular value decomposition of a rectangular matrix
svd(x, nu = min(n, p), nv = min(n, p), LINPACK = FALSE)
slice_head()
Select the first row/s
slice_head(.data, ..., n, prop, by = NULL)
slice_sample()
Select a random sample of rows
slice_sample(.data, ..., n, prop, by = NULL, weight_by = NULL, replace = FALSE)
slice_tail()
Select the last row/s
slice_tail(.data, ..., n, prop, by = NULL)
slice()
Filter rows based on its index/position
slice(.data, ..., .by = NULL, .preserve = FALSE)
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"), ...)
sort()
Sorts data in increasing or decreasing order
sort(x, decreasing = FALSE, ...)
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, ...)
split()
Divide the input data x into the groups defined by f
split(x, f, drop = FALSE, ...)
sprintf()
Print formatted strings
sprintf(fmt, ...)
sqrt()
Square root
sqrt(x)
starts_with()
Select columns starting with the given prefix (exact match)
starts_with(match, ignore.case = TRUE, vars = NULL)
stem()
Create a stem and leaf plot
stem(x, scale = 1, width = 80, atom = 1e-08)
stop()
Stops the execution of the current expression and displays an error message
stop(..., call. = TRUE, domain = NULL)
storage.mode()
Storage mode of an object
storage.mode(x)
str()
Structure of an object
str(object, ...)
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, ...)
strsplit()
Split a string into substrings based on a delimiter
strsplit(x, split, fixed = FALSE, perl = FALSE, useBytes = FALSE)
sub()
Replace the first pattern match
sub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)
subset()
Subset vectors, matrices or data frames based on conditions
subset(x, ...)
substr()
Extract or replace substrings of a character vector
substr(x, start, stop)
substring()
Extract or replace substrings of a character vector
substring(text, first, last = 1000000L)
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)
switch()
Evaluates an expression and chooses an option from a list of alternatives
switch(EXPR, ...)
Sys.Date()
Current date
Sys.sleep()
Suspend execution of R expressions for a specified time interval
Sys.sleep(time)
Sys.time()
Current date and time
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, ...)
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)
tail()
Last n rows/parts of an object
tail(x, n = 6L, keepnums = FALSE, addrownums, ...)
tan()
Tangent function
tan(x)
tapply()
Create group summaries based on factor levels
tapply(X, INDEX, FUN = NULL, ..., default = NA, simplify = TRUE)
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)
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, ...)
title()
Add a title to a plot
title(main = NULL, sub = NULL, xlab = NULL, ylab = NULL, line = NA, outer = FALSE, ...)
tolower()
Convert characters to lowercase
tolower(x)
toupper()
Convert characters to uppercase
toupper(x)
t()
Transpose of a matrix
t(x)
trimws()
Remove leading and/or trailing whitespaces
trimws(x, which = c("both", "left", "right"), whitespace = "[ \t\r\n]")
trunc()
Round values removing their decimal places
trunc(x, ...)
tryCatch()
Error and warning handling
tryCatch(expr, ..., finally)
txtProgressBar()
Text progress bar
txtProgressBar(min = 0, max = 1, initial = 0, char = "=", width = NA, title, label, style = 1, file = "")
typeof()
Type of an object
typeof(x)
unlink()
Delete files and directories
unlink(x, recursive = FALSE, force = FALSE, expand = TRUE)
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"))
var()
Compute the variance of a vector
var(x, y = NULL, na.rm = FALSE, use)
c()
Concatenate data of the same type
c(...)
warning()
Warning messages
warning(..., call. = TRUE, immediate. = FALSE, noBreaks. = FALSE, domain = NULL)
warnings()
Print last warning message
warnings(...)
weighted.mean()
Weighted arithmetic mean
weighted.mean(x, w, ..., na.rm = FALSE)
where()
Select columns for which a function returns TRUE
where(fn)
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, ...)
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)
winProgressBar()
Windows progress bar widget
winProgressBar(title = "R progress bar", label = "", min = 0, max = 1, initial = 0, width = 300)
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 = "")
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 = "")
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 = "")
X11()
Open a X11 graphic device
X11(display = "", width, height, pointsize, gamma, bg, canvas, fonts, family, xpos, ypos, title, type, antialias, symbolfamily)
xtabs()
Create a contingency table of the counts at each combination of factor levels using a formula
xtabs(formula = ~., data = parent.frame(), subset, sparse = FALSE, na.action, addNA = FALSE, exclude = if(!addNA) c(NA, NaN), drop.unused.levels = FALSE)