Loading...
Preparing your coding drills
Comprehensive reference for 45 R methods across 7 categories.
c
Combines values into a vector or list. The most fundamental function for creating vectors in R.
length
Returns the number of elements in a vector, list, or other R object.
append
Adds elements to a vector at a specified position. Returns a new vector.
rev
Returns a reversed version of the input vector or other object.
sort
Sorts a vector into ascending or descending order.
unique
Returns a vector with duplicate elements removed, preserving first occurrence order.
seq
Generates regular sequences. A versatile function for creating numeric sequences with various patterns.
rep
Replicates elements of a vector a specified number of times.
which
Returns the indices of elements that are TRUE in a logical vector. Essential for conditional indexing.
paste
Concatenates strings with a separator. One of the most commonly used string functions in R.
paste0
Concatenates strings without any separator. Equivalent to paste(..., sep = "").
nchar
Returns the number of characters in each element of a character vector.
gsub
Replaces all occurrences of a pattern in a string. Supports regular expressions by default.
substr
Extracts or replaces substrings in a character vector based on start and stop positions.
strsplit
Splits the elements of a character vector by a given delimiter.
toupper
Converts all characters in a string to uppercase.
tolower
Converts all characters in a string to lowercase.
trimws
Removes leading and/or trailing whitespace from strings.
data.frame
Creates a data frame from vectors, lists, or other data frames. The primary tabular data structure in R.
rbind
Combines data frames or matrices by rows (stacking them vertically). Columns must match.
cbind
Combines data frames, matrices, or vectors by columns (side by side). Rows must match.
merge
Merges two data frames by common columns (similar to SQL JOIN operations).
subset
Returns a subset of a data frame meeting conditions, optionally selecting specific columns.
names
Gets or sets the names (column names for data frames, element names for lists/vectors) of an object.
nrow
Returns the number of rows of a data frame or matrix.
ncol
Returns the number of columns of a data frame or matrix.
sapply
Applies a function to each element of a list or vector and simplifies the result to a vector or matrix.
lapply
Applies a function to each element of a list or vector and always returns a list.
tapply
Applies a function to groups of values, split by one or more factors. Useful for grouped summaries.
apply
Applies a function over the rows or columns of a matrix or data frame.
sum
Calculates the sum of all values in the arguments.
mean
Calculates the arithmetic mean of a numeric vector.
max
Returns the maximum value from the given arguments.
min
Returns the minimum value from the given arguments.
abs
Returns the absolute value of a numeric value or vector.
sqrt
Computes the square root of a numeric value or vector.
round
Rounds values to the specified number of decimal places.
ceiling
Rounds values up to the nearest integer (smallest integer not less than x).
floor
Rounds values down to the nearest integer (largest integer not greater than x).
list
Creates a list, which can hold elements of different types including other lists. The most flexible data structure in R.
unlist
Flattens a list into a vector by combining all elements.
is.na
Tests which elements of a vector are NA (missing values). Returns a logical vector.
ifelse
Vectorized conditional: returns values from yes or no depending on the test condition for each element.
match
Returns the positions of first matches of elements of x in table. The underlying function for the %in% operator.
%in%
Tests whether elements of x are present in table. Returns a logical vector. A binary operator shortcut for match().