Skip to content
R

base vector API Reference

R's base vector functions — vectors are the fundamental data structure in R, holding elements of one type.

By EZ4Code Team

vector functions

Base R functions for creating, inspecting and transforming vectors.

length(x) -> integer

Returns the number of elements in a vector or list.

Returns: integer

c(...) -> vector

Combines values into a vector or list, coercing to a common type.

Returns: vector

x[i] (subscript)

Extracts elements by integer, logical, or character index. Negative indices drop elements.

Returns: vector

sort(x, decreasing = FALSE) -> vector

Returns a sorted copy of the vector.

Returns: vector

unique(x) -> vector

Returns a vector with duplicate elements removed, preserving first occurrences.

Returns: vector

rev(x) -> vector

Returns a copy of the vector with elements in reverse order.

Returns: vector

sum(..., na.rm = FALSE) -> numeric

Returns the sum of all values. Use na.rm = TRUE to ignore NA values.

Returns: numeric

More R API References