Compute absolute values for numeric vectors. Converts negative numbers to positive, leaving zeros unchanged. Essential for distance and error calculations.
Reference
Base Functions
Core R functions available in base R.
- abs()
- apply()
Apply a function over the margins of an array or matrix in R. A core base R function for iterative operations on rectangular data structures.
- c()
Combine values into a vector or list. This is the most fundamental function in R for creating vectors, used extensively in data manipulation and programming.
- cat()
Concatenate and print objects to a file or connection, with minimal formatting.
- ceiling()
Round numeric values up to the nearest integer in R.
- class()
Get or set the class attribute of an R object. Returns the class vector for an object, or can be used to assign a new class.
- colnames()
Get or set the column names of a matrix, data frame, or other R object.
- cos()
Compute the trigonometric cosine of values in R.
- cummax()
Compute the cumulative maximum of a vector in R.
- cummin()
Compute the cumulative minimum of a vector in R.
- cumprod()
Compute the cumulative product of a vector in R.
- cumsum()
Compute the cumulative sum of a vector in R.
- diff()
Calculate lagged differences between elements in a vector, useful for detecting changes, trends, and rate of change in sequential data.
- dim()
Get or set the dimensions of an object (matrix, data frame, array).
- do.call
Call a function with arguments from a list or environment. Build a call expression with call() first, then evaluate it with do.call.
- duplicated()
Identify duplicate elements in R objects.
- exp()
Compute the exponential of values in R (e^x).
- expm1()
Compute exp(x) - 1 for small values of x, providing numerical stability.
- filter
Apply linear filters to time series — moving averages via convolution, autoregressive filters via recursion, with alignment and circular wrapping control.
- find
Locate which environment in the search path contains an object of a given name. Returns environment names or search path positions.
- floor()
Round numeric values down to the nearest integer in R.
- head()
Return the first or last parts of a vector, matrix, table, data frame or function.
- ifelse()
Transform elements based on a condition, returning one value if TRUE and another if FALSE.
- intersect()
Return the intersection of two vectors — elements common to both vectors.
- is.na()
Test for missing values (NA) in R objects.
- is.nan()
Test for NaN (Not a Number) values in R.
- is.null()
Test whether an object is NULL in R.
- is.numeric()
Test whether an object has numeric type in R.
- lapply()
Apply a function to each element of a list or vector, returning a list.
- length()
Get or set the length of a vector, list, or other R object in R
- log()
Compute the natural logarithm (base e) of values in R.
- log10()
Compute the logarithm of values in base 10.
- log1p()
Compute the natural logarithm of (1 + x) for small values of x, providing numerical stability.
- log2()
Compute the logarithm of values in base 2.
- Map
Apply a function to multiple arguments in R with Map. This base function wraps mapply with SIMPLIFY=FALSE, always returning a list of results.
- mapply()
Apply a function to multiple arguments in parallel — first elements together, then second elements, and so on.
- match()
Find element positions in a vector, returning indices of first matches.
- max()
Find the maximum value in a vector or across multiple arguments.
- mean()
Compute the arithmetic mean of a numeric vector, with optional trimming and NA handling.
- message
R base function to output diagnostic messages to stderr without halting execution.
- min()
Find the minimum value in a vector or across multiple arguments.
- ncol()
Get the number of columns in a matrix, array, or data frame. Returns NULL for vectors.
- negate
Flip a predicate function with purrr negate — TRUE becomes FALSE, FALSE becomes TRUE. Use to discard what you would keep, or keep what you would discard.
- nrow()
Get the number of rows in a matrix, array, or data frame. Returns NULL for vectors.
- on.exit
Register an expression to be evaluated when the enclosing function exits.
- order()
Return the permutation that sorts a vector, or sort multiple vectors by one.
- paste()
Concatenate strings with a separator, converting vectors to character and optionally collapsing into a single string.
- paste0()
Concatenate strings end-to-end without inserting separators between elements.
- position
Find positional indices of values in R vectors — which.max for maximum position, rank for order-based ranks, and order for sorting indices.
- print()
Print objects to the console or output connection. Generic function with methods for different object types.
- range()
Returns the minimum and maximum values of a numeric vector, or the smallest and largest strings alphabetically.
- readline()
Read a line from the console or a connection for interactive user input in R scripts.
- Reduce
Apply a binary function cumulatively to reduce a vector to a single value. Supports initial values, right-to-left reduction, and accumulate mode.
- rep()
Replicate elements of a vector or list a specified number of times, creating repeated sequences.
- rm()
Remove objects from the specified environment by name, freeing memory and reducing namespace clutter.
- round()
Round numeric values to a specified number of decimal places.
- rownames()
Get or set the row names of a matrix, data frame, or other R object.
- sample()
Sample random elements from a vector or take a random subset of elements for simulation, testing, or resampling.
- sapply()
Apply a function to each element of a vector or list, simplifying the result to a vector or matrix when possible.
- sd()
Compute the standard deviation of numeric vectors in R.
- seq()
Generate regular sequences of numbers with customizable start, end, length, and increment.
- setdiff()
Return elements in the first vector but not in the second — set difference operation.
- sin()
Compute the trigonometric sine of values in R.
- sort()
Sort a vector into ascending or descending order. Returns the input vector with elements arranged from smallest to largest.
- sprintf()
Format strings using C-style sprintf formatting to insert values into text templates.
- sqrt()
Compute the square root of values in R.
- stop
Signal an error and halt execution in R with stop(), including custom messages, call control, and condition objects.
- substr()
Extract or replace substrings in a character vector
- sum()
Calculate the sum of all elements in a vector or matrix, with optional handling of missing values.
- switch()
Select one alternative from a list based on an integer index or character string match. Returns the selected element or NULL when no match exists.
- Sys.sleep
Pause R execution for a specified number of seconds. Simple, side-effect-only delay for loops, retries, and rate-limiting.
- Sys.time
Get the current date and time as a POSIXct object representing seconds since the Unix epoch.
- system
Execute system commands from R. Runs shell commands and returns exit status or captured output.
- system2
Execute external commands from R, capturing output and exit status
- table()
Create contingency tables showing frequency counts for categorical variables, cross-tabulating one or more factors into a table of counts.
- tan()
Compute the trigonometric tangent of values in R.
- tapply()
Apply a function to each level of a factor or group in a vector, creating grouped summaries.
- trunc()
Truncate numeric values toward zero in R.
- tryCatch
Catch and handle R conditions including errors, warnings, and messages with tryCatch().
- union()
Return the union of two vectors — all unique elements from both vectors.
- unique()
Extract unique values from a vector or remove duplicated rows in R objects.
- vapply()
Apply a function to each element of a vector or list, returning a vector, matrix, or array with enforced type safety via FUN.VALUE.
- var()
Compute the variance of numeric vectors in R.
- warning
Signal a warning in R with warning(), controlling call display, warn levels, suppression, and custom handlers.
- which.max / which.min()
Find the index of the minimum or maximum value in a vector, essential for locating extreme values in R.
- which()
Return the indices of elements that satisfy a logical condition, enabling efficient filtering and subsetting in R.
- withCallingHandlers()
Register calling handlers for warnings, messages, and errors in R while preserving access to the call stack.
- writeLines()
Write text lines to a file or connection in R, with control over line endings and encoding.