Skip to content

datar.apis.base

module

datar.apis.base

APIs ported from r-base

Functions
  • abs_(x) (Any) Compute the absolute value of a vector</>
  • acos(x) (Any) Get the inverse cosine</>
  • acosh(x) (Any) Get the inverse hyperbolic cosine</>
  • all_(x, na_rm) (Any) Are all elements true</>
  • any_(x, na_rm) (Any) Is any element true</>
  • any_na(x) (Any) Check if anything in x is NA</>
  • append(x, values, after) (Any) Append values to the vector</>
  • arg(x) (Any) Angles of complex numbers</>
  • as_character(x) (Any) Convert a vector to a character vector</>
  • as_complex(x) (Any) Convert a vector to a complex vector</>
  • as_date(x, format, try_formats, optional, tz, origin) (Any) Convert an object to a datetime.date object</>
  • as_double(x) (Any) Convert a vector to a double vector</>
  • as_factor(x) (Any) Convert a vector to a factor vector</>
  • as_integer(x) (Any) Convert a vector to an integer vector</>
  • as_logical(x) (Any) Convert a vector to a logical vector</>
  • as_null(x) (Any) Convert anything to NULL</>
  • as_numeric(x) (Any) Convert a vector to a numeric vector</>
  • as_ordered(x) (Any) Convert a vector to an ordered vector</>
  • asin(x) (Any) Get the inverse sine</>
  • asinh(x) (Any) Get the inverse hyperbolic sine</>
  • atan(x) (Any) Get the inverse tangent</>
  • atan2(y, x) (Any) Get the inverse tangent of y/x</>
  • atanh(x) (Any) Get the inverse hyperbolic tangent</>
  • bessel_i(x, nu, expon_scaled) (Any) Compute the modified Bessel function of the first kind</>
  • bessel_j(x, nu) (Any) Compute the Bessel function of the first kind</>
  • bessel_k(x, nu, expon_scaled) (Any) Compute the modified Bessel function of the second kind</>
  • bessel_y(x, nu) (Any) Compute the Bessel function of the second kind</>
  • beta(x, y) (Any) Compute the beta function</>
  • c_(*args) (Any) Concatenate vectors</>
  • ceiling(x) (Any) Round up to the nearest integer</>
  • chartr(old, new, x) (Any) Translate characters</>
  • choose(n, k) (Any) Compute the binomial coefficient</>
  • col_means(x, na_rm) (Any) Compute the column means of a matrix</>
  • col_medians(x, na_rm) (Any) Compute the column medians of a matrix</>
  • col_sds(x, na_rm) (Any) Compute the column standard deviations of a matrix</>
  • col_sums(x, na_rm) (Any) Compute the column sums of a matrix</>
  • colnames(x, nested) (Any) Get the column names</>
  • complete_cases(x) (Any) Get the complete cases</>
  • conj(x) (Any) Complex conjugate</>
  • cos(x) (Any) Get the cosine</>
  • cosh(x) (Any) Get the hyperbolic cosine</>
  • cospi(x) (Any) Get the cosine of pi times x</>
  • cov(x, y, na_rm, ddof) (Any) Compute pairwise covariance between two variables</>
  • cummax(x) (Any) Cumulative maxima</>
  • cummin(x) (Any) Cumulative minima</>
  • cumprod(x) (Any) Cumulative products</>
  • cumsum(x) (Any) Cumulative sums</>
  • cut(x, breaks, labels, include_lowest, right, dig_lab, ordered_result) (Any) Cut a numeric vector into bins</>
  • diag(x, nrow, ncol) (Any) Get the diagonal of a matrix</>
  • diff(x, lag, differences) (An array of `x[lag) Difference of a numeric vector</>
  • digamma(x) (Any) Compute the digamma function</>
  • dim(x, nested) (Any) Get the dimensions</>
  • droplevels(x) (Any) Drop unused levels of a factor</>
  • duplicated(x, incomparables, from_last) (Any) Get the duplicated values</>
  • endswith(x, suffix) (Any) Does x end with suffix</>
  • exp(x) (Any) Compute the exponential of a vector</>
  • expand_grid(x, *args, **kwargs) (Any) Expand a grid</>
  • factor(x, levels, labels, exclude, ordered, nmax) (Any) Create a factor vector</>
  • factorial(x) (Any) Compute the factorial</>
  • floor(x) (Any) Round down to the nearest integer</>
  • gamma(x) (Any) Compute the gamma function</>
  • grep(pattern, x, ignore_case, value, fixed, invert) (Any) Grep for a pattern</>
  • grepl(pattern, x, ignore_case, fixed) (Any) Grep for a pattern</>
  • gsub(pattern, replacement, x, ignore_case, fixed) (Any) Substitute a pattern</>
  • head(x, n) (Any) Get the first n rows</>
  • identity(x) (Any) Identity function</>
  • im(x) (Any) Imaginary part of complex numbers</>
  • intersect(x, y) (Any) Get the intersection of two vectors</>
  • is_atomic(x) (Any) Is the object atomic</>
  • is_character(x) (Any) Is x a character vector</>
  • is_complex(x) (Any) Check if a vector is complex</>
  • is_double(x) (Any) Is the object a double</>
  • is_element(x, y) (Any) Is the object an element of the table</>
  • is_factor(x) (Any) Check if a vector is a factor</>
  • is_false(x) (bool) Check if anything is false</>
  • is_finite(x) (Any) Check if anything is finite</>
  • is_infinite(x) (Any) Check if anything is infinite</>
  • is_integer(x) (Any) Is the object an integer</>
  • is_logical(x) (Any) Check if a vector is logical</>
  • is_na(x) (Any) Check if anything is NA</>
  • is_null(x) (Any) Check if anything is NULL</>
  • is_numeric(x) (Any) Is the object numeric</>
  • is_ordered(x) (Any) Check if a vector is ordered</>
  • is_true(x) (bool) Check if anything is true</>
  • lbeta(x, y) (Any) Compute the log beta function</>
  • lchoose(n, k) (Any) Compute the log binomial coefficient</>
  • length(x) (Any) Get the length of a vector</>
  • lengths(x) (Any) Get the lengths of a list</>
  • levels(x) (Any) Get the levels of a factor</>
  • lfactorial(x) (Any) Compute the log factorial</>
  • lgamma(x) (Any) Compute the log gamma function</>
  • log(x, base) (Any) Compute the logarithm of a vector</>
  • log10(x) (Any) Compute the base 10 logarithm of a vector</>
  • log1p(x) (Any) Compute the logarithm of one plus a vector</>
  • log2(x) (Any) Compute the base-2 logarithm of a vector</>
  • make_names(names, unique) (Any) Make names for a vector</>
  • make_unique(names) (Any) Make a vector unique</>
  • match(x, table, nomatch) (Any) Match elements of a vector</>
  • max_(x, na_rm) (Any) Compute the maximum of a vector</>
  • max_col(x, ties_method, nested) (Any) Get the maximum column</>
  • mean(x, na_rm) (Any) Compute the mean of a vector</>
  • median(x, na_rm) (Any) Compute the median of a vector</>
  • min_(x, na_rm) (Any) Compute the minimum of a vector</>
  • mod(x) (Any) Modulus of complex numbers</>
  • nchar(x, type_, allow_na, keep_na, _na_len) (Any) Get the number of characters in a string</>
  • ncol(x, nested) (Any) Get the number of columns</>
  • nlevels(x) (Any) Get the number of levels of a factor</>
  • nrow(x) (Any) Get the number of rows</>
  • nzchar(x, keep_na) (Any) Is the string non-zero length</>
  • order(x, decreasing, na_last) (Any) Order a vector</>
  • ordered(x, levels, labels, exclude, nmax) (Any) Create an ordered factor vector</>
  • outer(x, y, fun) (Any) Outer product of two vectors</>
  • paste(*args, sep, collapse) (Any) Join a vector into a string</>
  • paste0(*args, collapse) (Any) Join a vector into a string</>
  • pmax(*args, na_rm) (Any) Returns the (regular or Parallel) maxima and minima of the input values. </>
  • pmin(*args, na_rm) (Any) Returns the (regular or Parallel) maxima and minima of the input values. </>
  • prod(x, na_rm) (Any) Compute the product of a vector</>
  • proportions(x, margin) (Any) Get the proportion table</>
  • psigamma(x, deriv) (Any) Compute the psi function</>
  • quantile(x, probs, na_rm, names, type_, digits) (Any) Compute the quantiles of a vector</>
  • rank(x, na_last, ties_method) (Any) Rank a numeric vector</>
  • rbinom(n, size, prob) (Any) Generate random binomial variables</>
  • rcauchy(n, location, scale) (Any) Generate random Cauchy variables</>
  • rchisq(n, df) (Any) Generate random chi-squared variables</>
  • re_(x) (Any) Real part of complex numbers</>
  • rep(x, times, length, each) (Any) Replicate elements of a vector</>
  • rev(x) (Any) Reverse a vector</>
  • rexp(n, rate) (Any) Generate random exponential variables</>
  • rnorm(n, mean, sd) (Any) Generate random normal variables</>
  • round_(x, digits) (Any) Round the values of a vector</>
  • row_means(x, na_rm) (Any) Compute the row means of a matrix</>
  • row_medians(x, na_rm) (Any) Compute the row medians of a matrix</>
  • row_sds(x, na_rm) (Any) Compute the row standard deviations of a matrix</>
  • row_sums(x, na_rm) (Any) Compute the row sums of a matrix</>
  • rownames(x) (Any) Get the row names</>
  • rpois(n, lambda_) (Any) Generate random Poisson variables</>
  • runif(n, min, max) (Any) Generate random uniform variables</>
  • sample(x, size, replace, prob) (Any) Sample a vector</>
  • scale(x, center, scale_) (Any) Center and/or scale the data</>
  • sd(x, na_rm) (Any) Compute the standard deviation of a vector</>
  • seq(from_, to, by, length_out, along_with) (Any) Generate a sequence</>
  • seq_along(x) (Any) Generate a sequence along a vector</>
  • seq_len(x) (Any) Generate a sequence of length x</>
  • set_colnames(x, names, nested) (Any) Set the column names</>
  • set_levels(x, levels) (Any) Set the levels of a factor</>
  • set_rownames(x, names) (Any) Set the row names</>
  • set_seed(seed) (Any) Set the seed of the random number generator</>
  • setdiff(x, y) (Any) Get the difference of two vectors</>
  • setequal(x, y) (Any) Check if two vectors are equal</>
  • sign(x) (Any) Compute the sign of a vector</>
  • signif(x, digits) (Any) Round the values of a vector to a given number of significant digits</>
  • sin(x) (Any) Get the sine</>
  • sinh(x) (Any) Get the hyperbolic sine</>
  • sinpi(x) (Any) Get the sine of pi times x</>
  • sort(x, decreasing, na_last) (Any) Sort a vector</>
  • sprintf(fmt, *args) (Any) Format a string</>
  • sqrt(x) (Any) Compute the square root of a vector</>
  • startswith(x, prefix) (Any) Does x start with prefix</>
  • strsplit(x, split, fixed, perl, use_bytes) (Any) Split a string</>
  • strtoi(x, base) (Any) Convert a string to an integer</>
  • sub(pattern, replacement, x, ignore_case, fixed) (Any) Substitute a pattern</>
  • substr(x, start, stop) (Any) Get a substring</>
  • substring(x, first, last) (Any) Get a substring</>
  • sum_(x, na_rm) (Any) Compute the sum of a vector</>
  • t(x) (Any) Get the transpose</>
  • table(x, *more, exclude, use_na, dnn, deparse_level) (Any) Get the table of a vector</>
  • tabulate(bin, nbins) (Any) Get the table of a vector</>
  • tail(x, n) (Any) Get the last n rows</>
  • tan(x) (Any) Get the tangent</>
  • tanh(x) (Any) Get the hyperbolic tangent</>
  • tanpi(x) (Any) Get the tangent of pi times x</>
  • tolower(x) (Any) Convert a string to lower case</>
  • toupper(x) (Any) Convert a string to upper case</>
  • trigamma(x) (Any) Compute the trigamma function</>
  • trimws(x, which, whitespace) (Any) Trim whitespace from a string</>
  • trunc(x) (Any) Truncate the values of a vector</>
  • union(x, y) (Any) Get the union of two vectors</>
  • unique(x) (Any) Get the unique values</>
  • var(x, na_rm, ddof) (Any) Compute the variance of a vector</>
  • weighted_mean(x, w, na_rm) (Any) Compute the weighted mean of a vector</>
  • which(x) (Any) Get the indices of the non-zero values</>
  • which_max(x) (Any) Get the index of the maximum value</>
  • which_min(x) (Any) Get the index of the minimum value</>
function

datar.apis.base.ceiling(x)

Round up to the nearest integer

Parameters
  • x The value to be rounded up
Returns (Any)

The rounded up value

function

datar.apis.base.cov(x, y=None, na_rm=False, ddof=1)

Compute pairwise covariance between two variables

Parameters
  • x a numeric vector, matrix or data frame.
  • y (optional) None or a vector, matrix or data frame withcompatible dimensions to x. The default is equivalent to y = x
  • na_rm (bool, optional) If True, remove missing values before computingthe covariance.
  • ddof (int, optional) The denominator degrees of freedom.
Returns (Any)

The covariance matrix

function

datar.apis.base.floor(x)

Round down to the nearest integer

Parameters
  • x The value to be rounded down
Returns (Any)

The rounded down value

function

datar.apis.base.mean(x, na_rm=False)

Compute the mean of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The mean of the vector

function

datar.apis.base.median(x, na_rm=False)

Compute the median of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The median of the vector

function

datar.apis.base.pmax(*args, na_rm=False)

Returns the (regular or Parallel) maxima and minima of the input values.

Parameters
  • na_rm (bool, optional) Whether to remove NA values
  • x A numeric vector
  • more One or more values
Returns (Any)

The maximum of the vector and the values

function

datar.apis.base.pmin(*args, na_rm=False)

Returns the (regular or Parallel) maxima and minima of the input values.

Parameters
  • na_rm (bool, optional) Whether to remove NA values
  • x A numeric vector
  • more One or more values
Returns (Any)

The minimum of the vector and the values

function

datar.apis.base.sqrt(x)

Compute the square root of a vector

Parameters
  • x A numeric vector
Returns (Any)

The square root of the vector

function

datar.apis.base.var(x, na_rm=False, ddof=1)

Compute the variance of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
  • ddof (int, optional) The degrees of freedom
  • y None or a vector, matrix or data frame withcompatible dimensions to x. The default is equivalent to y = x
Returns (Any)

The variance of the vector

function

datar.apis.base.scale(x, center=True, scale_=True)

Center and/or scale the data

Parameters
  • x A numeric vector
  • center (optional) Whether to center the data
  • scale_ (optional) Whether to scale the data
Returns (Any)

The scaled data

function

datar.apis.base.col_sums(x, na_rm=False)

Compute the column sums of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The column sums of the matrix

function

datar.apis.base.col_means(x, na_rm=False)

Compute the column means of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The column means of the matrix

function

datar.apis.base.col_sds(x, na_rm=False)

Compute the column standard deviations of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The column standard deviations of the matrix

function

datar.apis.base.col_medians(x, na_rm=False)

Compute the column medians of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The column medians of the matrix

function

datar.apis.base.row_sums(x, na_rm=False)

Compute the row sums of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The row sums of the matrix

function

datar.apis.base.row_means(x, na_rm=False)

Compute the row means of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The row means of the matrix

function

datar.apis.base.row_sds(x, na_rm=False)

Compute the row standard deviations of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The row standard deviations of the matrix

function

datar.apis.base.row_medians(x, na_rm=False)

Compute the row medians of a matrix

Parameters
  • x A numeric matrix
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The row medians of the matrix

function

datar.apis.base.min_(x, na_rm=False)

Compute the minimum of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The minimum of the vector

function

datar.apis.base.max_(x, na_rm=False)

Compute the maximum of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The maximum of the vector

function

datar.apis.base.round_(x, digits=0)

Round the values of a vector

Parameters
  • x A numeric vector
  • digits (int, optional) The number of digits to round to
Returns (Any)

The rounded values

function

datar.apis.base.sum_(x, na_rm=False)

Compute the sum of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The sum of the vector

function

datar.apis.base.abs_(x)

Compute the absolute value of a vector

Parameters
  • x A numeric vector
Returns (Any)

The absolute values of the vector

function

datar.apis.base.prod(x, na_rm=False)

Compute the product of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The product of the vector

function

datar.apis.base.sign(x)

Compute the sign of a vector

Parameters
  • x A numeric vector
Returns (Any)

The signs of the vector

function

datar.apis.base.signif(x, digits=6)

Round the values of a vector to a given number of significant digits

Parameters
  • x A numeric vector
  • digits (int, optional) The number of significant digits to round to
Returns (Any)

The rounded values

function

datar.apis.base.trunc(x)

Truncate the values of a vector

Parameters
  • x A numeric vector
Returns (Any)

The truncated values

function

datar.apis.base.exp(x)

Compute the exponential of a vector

Parameters
  • x A numeric vector
Returns (Any)

The exponential values

function

datar.apis.base.log(x, base=2.718281828459045)

Compute the logarithm of a vector

Parameters
  • x A numeric vector
  • base (float, optional) The base of the logarithm
Returns (Any)

The logarithm values

function

datar.apis.base.log2(x)

Compute the base-2 logarithm of a vector

Parameters
  • x A numeric vector
Returns (Any)

The logarithm values

function

datar.apis.base.log10(x)

Compute the base 10 logarithm of a vector

Parameters
  • x A numeric vector
Returns (Any)

The logarithm values

function

datar.apis.base.log1p(x)

Compute the logarithm of one plus a vector

Parameters
  • x A numeric vector
Returns (Any)

The logarithm values

function

datar.apis.base.sd(x, na_rm=False)

Compute the standard deviation of a vector

Parameters
  • x A numeric vector
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The standard deviation of the vector

function

datar.apis.base.weighted_mean(x, w=None, na_rm=False)

Compute the weighted mean of a vector

Parameters
  • x A numeric vector
  • w (optional) The weights to use
  • na_rm (bool, optional) Whether to remove NA values
Returns (Any)

The weighted mean of the vector

function

datar.apis.base.quantile(x, probs=(0.0, 0.25, 0.5, 0.75, 1.0), na_rm=False, names=True, type_=7, digits=7)

Compute the quantiles of a vector

Parameters
  • x A numeric vector
  • probs (optional) The probabilities to use
Returns (Any)

The quantiles of the vector

function

datar.apis.base.bessel_i(x, nu, expon_scaled=False)

Compute the modified Bessel function of the first kind

Parameters
  • x A numeric vector
  • nu The order of the Bessel function
  • expon_scaled (bool, optional) Whether to use the scaled version
Returns (Any)

The Bessel function values

function

datar.apis.base.bessel_j(x, nu)

Compute the Bessel function of the first kind

Parameters
  • x A numeric vector
  • nu The order of the Bessel function
Returns (Any)

The Bessel function values

function

datar.apis.base.bessel_k(x, nu, expon_scaled=False)

Compute the modified Bessel function of the second kind

Parameters
  • x A numeric vector
  • nu The order of the Bessel function
  • expon_scaled (bool, optional) Whether to use the scaled version
Returns (Any)

The Bessel function values

function

datar.apis.base.bessel_y(x, nu)

Compute the Bessel function of the second kind

Parameters
  • x A numeric vector
  • nu The order of the Bessel function
Returns (Any)

The Bessel function values

function

datar.apis.base.as_double(x)

Convert a vector to a double vector

Parameters
  • x A numeric vector
Returns (Any)

The double vector

function

datar.apis.base.as_integer(x)

Convert a vector to an integer vector

Parameters
  • x A numeric vector
Returns (Any)

The integer vector

function

datar.apis.base.as_logical(x)

Convert a vector to a logical vector

Parameters
  • x A numeric vector
Returns (Any)

The logical vector

function

datar.apis.base.as_character(x)

Convert a vector to a character vector

Parameters
  • x A numeric vector
Returns (Any)

The character vector

function

datar.apis.base.as_factor(x)

Convert a vector to a factor vector

Parameters
  • x A numeric vector
Returns (Any)

The factor vector

function

datar.apis.base.as_ordered(x)

Convert a vector to an ordered vector

Parameters
  • x A numeric vector
Returns (Any)

The ordered vector

function

datar.apis.base.as_date(x, format=None, try_formats=None, optional=False, tz=0, origin=None)

Convert an object to a datetime.date object

See: https://rdrr.io/r/base/as.Date.html

Parameters
  • x Object that can be converted into a datetime.date object
  • format (optional) If not specified, it will try try_formats one by one onthe first non-np.nan element, and give an error if none works. Otherwise, the processing is via strptime
  • try_formats (optional) vector of format strings to try if format is not specified.Default formats to try: "%Y-%m-%d" "%Y/%m/%d" "%Y-%m-%d %H:%M:%S" "%Y/%m/%d %H:%M:%S"
  • optional (optional) indicating to return np.nan (instead of signalling an error)if the format guessing does not succeed.
  • tz (optional) a time zone offset or a datetime.timedelta object.Note that time zone name is not supported yet.
  • origin (optional) a datetime.date/datetime object, or something which can becoerced by as_date(origin, ...) to such an object.
Returns (Any)

The datetime.date object

function

datar.apis.base.as_numeric(x)

Convert a vector to a numeric vector

Parameters
  • x A numeric vector
Returns (Any)

The numeric vector

function

datar.apis.base.arg(x)

Angles of complex numbers

Parameters
  • x A numeric vector
Returns (Any)

The angles

function

datar.apis.base.conj(x)

Complex conjugate

Parameters
  • x A numeric vector
Returns (Any)

The complex conjugates

function

datar.apis.base.mod(x)

Modulus of complex numbers

Parameters
  • x A numeric vector
Returns (Any)

The modulus

function

datar.apis.base.re_(x)

Real part of complex numbers

Parameters
  • x A numeric vector
Returns (Any)

The real parts

function

datar.apis.base.im(x)

Imaginary part of complex numbers

Parameters
  • x A numeric vector
Returns (Any)

The imaginary parts

function

datar.apis.base.as_complex(x)

Convert a vector to a complex vector

Parameters
  • x A numeric vector
Returns (Any)

The complex vector

function

datar.apis.base.is_complex(x)

Check if a vector is complex

Parameters
  • x A numeric vector
Returns (Any)

Whether the vector is complex

function

datar.apis.base.cummax(x)

Cumulative maxima

Parameters
  • x A numeric vector
Returns (Any)

The cumulative maxima

function

datar.apis.base.cummin(x)

Cumulative minima

Parameters
  • x A numeric vector
Returns (Any)

The cumulative minima

function

datar.apis.base.cumprod(x)

Cumulative products

Parameters
  • x A numeric vector
Returns (Any)

The cumulative products

function

datar.apis.base.cumsum(x)

Cumulative sums

Parameters
  • x A numeric vector
Returns (Any)

The cumulative sums

function

datar.apis.base.droplevels(x)

Drop unused levels of a factor

Parameters
  • x A numeric vector
Returns (Any)

The factor vector

function

datar.apis.base.levels(x)

Get the levels of a factor

Parameters
  • x A numeric vector
Returns (Any)

The factor vector

function

datar.apis.base.set_levels(x, levels)

Set the levels of a factor

Parameters
  • x A numeric vector
  • levels The new levels
Returns (Any)

The factor vector

function

datar.apis.base.is_factor(x)

Check if a vector is a factor

Parameters
  • x A numeric vector
Returns (Any)

Whether the vector is a factor

function

datar.apis.base.is_ordered(x)

Check if a vector is ordered

Parameters
  • x A numeric vector
Returns (Any)

Whether the vector is ordered

function

datar.apis.base.nlevels(x)

Get the number of levels of a factor

Parameters
  • x A numeric vector
Returns (Any)

The number of levels

function

datar.apis.base.factor(x=None, levels=None, labels=None, exclude=None, ordered=False, nmax=None)

Create a factor vector

Parameters
  • x (optional) A numeric vector
  • levels (optional) The levels
  • labels (optional) The labels
  • exclude (optional) The excluded levels
  • ordered (optional) Whether the factor is ordered
  • nmax (optional) The maximum number of levels
Returns (Any)

The factor vector

function

datar.apis.base.ordered(x, levels=None, labels=None, exclude=None, nmax=None)

Create an ordered factor vector

Parameters
  • x A numeric vector
  • levels (optional) The levels
  • labels (optional) The labels
  • exclude (optional) The excluded levels
  • nmax (optional) The maximum number of levels
Returns (Any)

The ordered factor vector

function

datar.apis.base.cut(x, breaks, labels=None, include_lowest=False, right=True, dig_lab=3, ordered_result=False)

Cut a numeric vector into bins

Parameters
  • x A numeric vector
  • breaks The breaks
  • labels (optional) The labels
  • include_lowest (optional) Whether to include the lowest value
  • right (optional) Whether to include the rightmost value
  • dig_lab (optional) The number of digits for labels
  • ordered_result (optional) Whether to return an ordered factor
Returns (Any)

The factor vector

function

datar.apis.base.diff(x, lag=1, differences=1)

Difference of a numeric vector

Parameters
  • x A numeric vector
  • lag (int, optional) The lag to use. Could be negative.It always calculates x[lag:] - x[:-lag] even when lag is negative
  • differences (int, optional) The order of the difference
Returns (An array of `x[lag)

] – x[:-lag].Ifdifferences > 1, the rule appliesdifferencestimes onx`

function

datar.apis.base.expand_grid(x, *args, **kwargs)

Expand a grid

Parameters
  • x A numeric vector
  • *args Additional numeric vectors
  • **kwargs Additional keyword arguments
Returns (Any)

The expanded grid

function

datar.apis.base.outer(x, y, fun='*')

Outer product of two vectors

Parameters
  • x A numeric vector
  • y A numeric vector
  • fun (optional) The function to handle how the result of the elements fromthe first and second vectors should be computed. The function has to be vectorized at the second argument, and return the same shape as y.
Returns (Any)

The outer product

function

datar.apis.base.make_names(names, unique=True)

Make names for a vector

Parameters
  • names character vector to be coerced to syntactically valid names.This is coerced to character if necessary.
  • unique (bool, optional) Whether to make the names unique
Returns (Any)

The names

function

datar.apis.base.make_unique(names)

Make a vector unique

Parameters
  • names a character vector
Returns (Any)

The unique vector

function

datar.apis.base.rank(x, na_last=True, ties_method='average')

Rank a numeric vector

Parameters
  • x A numeric vector
  • na_last (bool, optional) Whether to put NA at the end
  • ties_method (str, optional) The method to handle ties. One of "average", "first","last", "random", "max", "min"
Returns (Any)

The ranks

function

datar.apis.base.identity(x)

Identity function

Parameters
  • x A numeric vector
Returns (Any)

The same vector

function

datar.apis.base.is_logical(x)

Check if a vector is logical

Parameters
  • x A numeric vector
Returns (Any)

Whether the vector is logical

function

datar.apis.base.is_true(x)

Check if anything is true

Parameters
  • x object to be tested
Returns (bool)

Whether x is true

function

datar.apis.base.is_false(x)

Check if anything is false

Parameters
  • x object to be tested
Returns (bool)

Whether x is false

function

datar.apis.base.is_na(x)

Check if anything is NA

Parameters
  • x object to be tested
Returns (Any)

Whether x is NA

function

datar.apis.base.is_finite(x)

Check if anything is finite

Parameters
  • x object to be tested
Returns (Any)

Whether x is finite

function

datar.apis.base.is_infinite(x)

Check if anything is infinite

Parameters
  • x object to be tested
Returns (Any)

Whether x is infinite

function

datar.apis.base.any_na(x)

Check if anything in x is NA

Parameters
  • x object to be tested
Returns (Any)

Whether anything in x is NA

function

datar.apis.base.as_null(x)

Convert anything to NULL

Parameters
  • x object to be converted
Returns (Any)

NULL

function

datar.apis.base.is_null(x)

Check if anything is NULL

Parameters
  • x object to be tested
Returns (Any)

Whether x is NULL

function

datar.apis.base.set_seed(seed) → Any

Set the seed of the random number generator

Parameters
  • seed The seed
function

datar.apis.base.rep(x, times=1, length=None, each=1)

Replicate elements of a vector

Parameters
  • x a vector or scaler
  • times (optional) number of times to repeat each element if of length len(x),or to repeat the whole vector if of length 1
  • length (optional) non-negative integer. The desired length of the output vector
  • each (optional) non-negative integer. Each element of x is repeated each times.
Returns (Any)

The replicated vector

function

datar.apis.base.c_(*args)

Concatenate vectors

Parameters
  • args vectors to be concatenated
Returns (Any)

The concatenated vector

function

datar.apis.base.length(x)

Get the length of a vector

Parameters
  • x a vector or scaler
Returns (Any)

The length of the vector

function

datar.apis.base.lengths(x)

Get the lengths of a list

Parameters
  • x a list
Returns (Any)

The lengths of the list

function

datar.apis.base.order(x, decreasing=False, na_last=True)

Order a vector

Parameters
  • x a vector or scaler
  • decreasing (bool, optional) Whether to order in decreasing order
  • na_last (bool, optional) Whether to put NA at the end
Returns (Any)

The order

function

datar.apis.base.sort(x, decreasing=False, na_last=True)

Sort a vector

Parameters
  • x a vector or scaler
  • decreasing (bool, optional) Whether to sort in decreasing order
  • na_last (bool, optional) Whether to put NA at the end
Returns (Any)

The sorted vector

function

datar.apis.base.rev(x)

Reverse a vector

Parameters
  • x a vector or scaler
Returns (Any)

The reversed vector

function

datar.apis.base.sample(x, size=None, replace=False, prob=None)

Sample a vector

Parameters
  • x a vector or scaler
  • size (optional) the size of the sample
  • replace (bool, optional) whether to sample with replacement
  • prob (optional) the probabilities of sampling each element
Returns (Any)

The sampled vector

function

datar.apis.base.seq(from_=None, to=None, by=None, length_out=None, along_with=None)

Generate a sequence

Parameters
  • from_ (optional) the start of the sequence
  • to (optional) the end of the sequence
  • by (optional) the step of the sequence
  • length_out (optional) the length of the sequence
  • along_with (optional) the sequence to be aligned with
Returns (Any)

The sequence

function

datar.apis.base.seq_along(x)

Generate a sequence along a vector

Parameters
  • x a vector or scaler
Returns (Any)

The sequence

function

datar.apis.base.seq_len(x)

Generate a sequence of length x

Parameters
  • x a vector or scaler
Returns (Any)

The sequence

function

datar.apis.base.match(x, table, nomatch=-1)

Match elements of a vector

Parameters
  • x a vector or scaler
  • table the table to match
  • nomatch (optional) the value to use for no match
Returns (Any)

The matched vector

function

datar.apis.base.beta(x, y)

Compute the beta function

Parameters
  • x a vector or scaler
  • y a vector or scaler
Returns (Any)

The beta function

function

datar.apis.base.lgamma(x)

Compute the log gamma function

Parameters
  • x a vector or scaler
Returns (Any)

The log gamma function

function

datar.apis.base.digamma(x)

Compute the digamma function

Parameters
  • x a vector or scaler
Returns (Any)

The digamma function

function

datar.apis.base.trigamma(x)

Compute the trigamma function

Parameters
  • x a vector or scaler
Returns (Any)

The trigamma function

function

datar.apis.base.choose(n, k)

Compute the binomial coefficient

Parameters
  • n a vector or scaler
  • k a vector or scaler
Returns (Any)

The binomial coefficient

function

datar.apis.base.factorial(x)

Compute the factorial

Parameters
  • x a vector or scaler
Returns (Any)

The factorial

function

datar.apis.base.gamma(x)

Compute the gamma function

Parameters
  • x a vector or scaler
Returns (Any)

The gamma function

function

datar.apis.base.lfactorial(x)

Compute the log factorial

Parameters
  • x a vector or scaler
Returns (Any)

The log factorial

function

datar.apis.base.lchoose(n, k)

Compute the log binomial coefficient

Parameters
  • n a vector or scaler
  • k a vector or scaler
Returns (Any)

The log binomial coefficient

function

datar.apis.base.lbeta(x, y)

Compute the log beta function

Parameters
  • x a vector or scaler
  • y a vector or scaler
Returns (Any)

The log beta function

function

datar.apis.base.psigamma(x, deriv)

Compute the psi function

Parameters
  • x a vector or scaler
  • deriv the derivative
Returns (Any)

The psi function

function

datar.apis.base.rnorm(n, mean=0, sd=1)

Generate random normal variables

Parameters
  • n the number of random variables
  • mean (optional) the mean of the random variables
  • sd (optional) the standard deviation of the random variables
Returns (Any)

The random normal variables

function

datar.apis.base.runif(n, min=0, max=1)

Generate random uniform variables

Parameters
  • n the number of random variables
  • min (optional) the minimum of the random variables
  • max (optional) the maximum of the random variables
Returns (Any)

The random uniform variables

function

datar.apis.base.rpois(n, lambda_)

Generate random Poisson variables

Parameters
  • n the number of random variables
  • lambda_ the lambda of the random variables
Returns (Any)

The random Poisson variables

function

datar.apis.base.rbinom(n, size, prob)

Generate random binomial variables

Parameters
  • n the number of random variables
  • size the size of the random variables
  • prob the probability of the random variables
Returns (Any)

The random binomial variables

function

datar.apis.base.rcauchy(n, location=0, scale=1)

Generate random Cauchy variables

Parameters
  • n the number of random variables
  • location (optional) the location of the random variables
  • scale (optional) the scale of the random variables
Returns (Any)

The random Cauchy variables

function

datar.apis.base.rchisq(n, df)

Generate random chi-squared variables

Parameters
  • n the number of random variables
  • df the degrees of freedom of the random variables
Returns (Any)

The random chi-squared variables

function

datar.apis.base.rexp(n, rate)

Generate random exponential variables

Parameters
  • n the number of random variables
  • rate the rate of the random variables
Returns (Any)

The random exponential variables

function

datar.apis.base.is_character(x)

Is x a character vector

Parameters
  • x a vector or scaler
Returns (Any)

True if x is a character vector

function

datar.apis.base.grep(pattern, x, ignore_case=False, value=False, fixed=False, invert=False)

Grep for a pattern

Parameters
  • pattern the pattern to search for
  • x the vector to search
  • ignore_case (optional) ignore case
  • value (optional) return the value
  • fixed (optional) use fixed string matching
  • invert (optional) invert the match
Returns (Any)

The indices of the matches

function

datar.apis.base.grepl(pattern, x, ignore_case=False, fixed=False)

Grep for a pattern

Parameters
  • pattern the pattern to search for
  • x the vector to search
  • ignore_case (optional) ignore case
  • fixed (optional) use fixed string matching
Returns (Any)

The indices of the matches

function

datar.apis.base.sub(pattern, replacement, x, ignore_case=False, fixed=False)

Substitute a pattern

Parameters
  • pattern the pattern to search for
  • replacement the replacement
  • x the vector to search
  • ignore_case (optional) ignore case
  • fixed (optional) use fixed string matching
Returns (Any)

The vector with the substitutions

function

datar.apis.base.gsub(pattern, replacement, x, ignore_case=False, fixed=False)

Substitute a pattern

Parameters
  • pattern the pattern to search for
  • replacement the replacement
  • x the vector to search
  • ignore_case (optional) ignore case
  • fixed (optional) use fixed string matching
Returns (Any)

The vector with the substitutions

function

datar.apis.base.strsplit(x, split, fixed=False, perl=False, use_bytes=False)

Split a string

Parameters
  • x the vector to split
  • split the pattern to split on
  • fixed (optional) use fixed string matching
  • perl (optional) use perl regular expressions
  • use_bytes (optional) use bytes
Returns (Any)

The vector with the splits

function

datar.apis.base.paste(*args, sep=' ', collapse=None)

Join a vector into a string

Parameters
  • *args the vector to join
  • sep (optional) the separator
  • collapse (optional) collapse the vector
Returns (Any)

The vector joined into a string

function

datar.apis.base.paste0(*args, collapse=None)

Join a vector into a string

Parameters
  • *args the vector to join
  • collapse (optional) collapse the vector
Returns (Any)

The vector joined into a string

function

datar.apis.base.sprintf(fmt, *args)

Format a string

Parameters
  • fmt the format string
  • args the arguments to the format string
Returns (Any)

The formatted string

function

datar.apis.base.substr(x, start, stop)

Get a substring

Parameters
  • x the string to get the substring from
  • start the start of the substring
  • stop the stop of the substring
Returns (Any)

The substring

function

datar.apis.base.substring(x, first, last=None)

Get a substring

Parameters
  • x the string to get the substring from
  • first the start of the substring
  • last (optional) the stop of the substring
Returns (Any)

The substring

function

datar.apis.base.startswith(x, prefix)

Does x start with prefix

Parameters
  • x the string to check
  • prefix the prefix to check
Returns (Any)

True if x starts with prefix

function

datar.apis.base.endswith(x, suffix)

Does x end with suffix

Parameters
  • x the string to check
  • suffix the suffix to check
Returns (Any)

True if x ends with suffix

function

datar.apis.base.strtoi(x, base=0)

Convert a string to an integer

Parameters
  • x the string to convert
  • base (optional) the base of the integer
Returns (Any)

The integer

function

datar.apis.base.trimws(x, which='both', whitespace=' \\t')

Trim whitespace from a string

Parameters
  • x the string to trim
  • which (optional) which whitespace to trim
  • whitespace (optional) the whitespace to trim
Returns (Any)

The trimmed string

function

datar.apis.base.toupper(x)

Convert a string to upper case

Parameters
  • x the string to convert
Returns (Any)

The upper case string

function

datar.apis.base.tolower(x)

Convert a string to lower case

Parameters
  • x the string to convert
Returns (Any)

The lower case string

function

datar.apis.base.chartr(old, new, x)

Translate characters

Parameters
  • old the characters to translate
  • new the new characters
  • x the string to translate
Returns (Any)

The translated string

function

datar.apis.base.nchar(x, type_='width', allow_na=True, keep_na=False, _na_len=2)

Get the number of characters in a string

Parameters
  • x the string to count
  • allow_na (bool, optional) allow NA
  • keep_na (bool, optional) keep NA
  • type the type of count
Returns (Any)

The number of characters

function

datar.apis.base.nzchar(x, keep_na=False)

Is the string non-zero length

Parameters
  • x the string to check
  • keep_na (bool, optional) keep NA
Returns (Any)

True if the string is non-zero length

function

datar.apis.base.table(x, *more, exclude=None, use_na='no', dnn=None, deparse_level=1)

Get the table of a vector

Parameters
  • x the vector to get the table of
  • exclude (optional) exclude these values
  • use_na (optional) use NA
  • dnn (optional) the names of the vectors
  • deparse_level (optional) the deparse level
  • more more vectors
Returns (Any)

The table

function

datar.apis.base.tabulate(bin, nbins=None)

Get the table of a vector

Parameters
  • bin the vector to get the table of
  • nbins (optional) the number of bins
Returns (Any)

An integer valued 'integer' vector (without names).There is a bin for each of the values '1, ..., nbins'

function

datar.apis.base.is_atomic(x)

Is the object atomic

Parameters
  • x the object to check
Returns (Any)

True if the object is atomic

function

datar.apis.base.is_double(x)

Is the object a double

Parameters
  • x the object to check
Returns (Any)

True if the object is a double

function

datar.apis.base.is_element(x, y)

Is the object an element of the table

Parameters
  • x the object to check
  • y the pool to check
Returns (Any)

True if the object is an element of the pool

function

datar.apis.base.is_integer(x)

Is the object an integer

Parameters
  • x the object to check
Returns (Any)

True if the object is an integer

function

datar.apis.base.is_numeric(x)

Is the object numeric

Parameters
  • x the object to check
Returns (Any)

True if the object is numeric

function

datar.apis.base.any_(x, na_rm=False)

Is any element true

Parameters
  • x the vector to check
  • na_rm (bool, optional) remove NA
Returns (Any)

True if any element is true

function

datar.apis.base.all_(x, na_rm=False)

Are all elements true

Parameters
  • x the vector to check
  • na_rm (bool, optional) remove NA
Returns (Any)

True if all elements are true

function

datar.apis.base.acos(x)

Get the inverse cosine

Parameters
  • x the value to get the inverse cosine of
Returns (Any)

The inverse cosine

function

datar.apis.base.acosh(x)

Get the inverse hyperbolic cosine

Parameters
  • x the value to get the inverse hyperbolic cosine of
Returns (Any)

The inverse hyperbolic cosine

function

datar.apis.base.asin(x)

Get the inverse sine

Parameters
  • x the value to get the inverse sine of
Returns (Any)

The inverse sine

function

datar.apis.base.asinh(x)

Get the inverse hyperbolic sine

Parameters
  • x the value to get the inverse hyperbolic sine of
Returns (Any)

The inverse hyperbolic sine

function

datar.apis.base.atan(x)

Get the inverse tangent

Parameters
  • x the value to get the inverse tangent of
Returns (Any)

The inverse tangent

function

datar.apis.base.atanh(x)

Get the inverse hyperbolic tangent

Parameters
  • x the value to get the inverse hyperbolic tangent of
Returns (Any)

The inverse hyperbolic tangent

function

datar.apis.base.cos(x)

Get the cosine

Parameters
  • x the value to get the cosine of
Returns (Any)

The cosine

function

datar.apis.base.cosh(x)

Get the hyperbolic cosine

Parameters
  • x the value to get the hyperbolic cosine of
Returns (Any)

The hyperbolic cosine

function

datar.apis.base.cospi(x)

Get the cosine of pi times x

Parameters
  • x the value to get the cosine of pi times x of
Returns (Any)

The cosine of pi times x

function

datar.apis.base.sin(x)

Get the sine

Parameters
  • x the value to get the sine of
Returns (Any)

The sine

function

datar.apis.base.sinh(x)

Get the hyperbolic sine

Parameters
  • x the value to get the hyperbolic sine of
Returns (Any)

The hyperbolic sine

function

datar.apis.base.sinpi(x)

Get the sine of pi times x

Parameters
  • x the value to get the sine of pi times x of
Returns (Any)

The sine of pi times x

function

datar.apis.base.tan(x)

Get the tangent

Parameters
  • x the value to get the tangent of
Returns (Any)

The tangent

function

datar.apis.base.tanh(x)

Get the hyperbolic tangent

Parameters
  • x the value to get the hyperbolic tangent of
Returns (Any)

The hyperbolic tangent

function

datar.apis.base.tanpi(x)

Get the tangent of pi times x

Parameters
  • x the value to get the tangent of pi times x of
Returns (Any)

The tangent of pi times x

function

datar.apis.base.atan2(y, x)

Get the inverse tangent of y/x

Parameters
  • y the numerator
  • x the denominator
Returns (Any)

The inverse tangent of y/x

function

datar.apis.base.append(x, values, after=-1)

Append values to the vector

Parameters
  • x the vector to append to
  • values the values to append
  • after (int, optional) the index to append after
Returns (Any)

The vector with the values appended

function

datar.apis.base.colnames(x, nested=True)

Get the column names

Parameters
  • x the data frame to get the column names of
  • nested (bool, optional) whether x is a nested data frame
Returns (Any)

The column names

function

datar.apis.base.set_colnames(x, names, nested=True)

Set the column names

Parameters
  • x the data frame to set the column names of
  • names the column names to set
  • nested (bool, optional) whether the frame are nested
Returns (Any)

The data frame with the column names set

function

datar.apis.base.rownames(x)

Get the row names

Parameters
  • x the data frame to get the row names of
Returns (Any)

The row names

function

datar.apis.base.set_rownames(x, names)

Set the row names

Parameters
  • x the data frame to set the row names of
  • names the row names to set
Returns (Any)

The data frame with the row names set

function

datar.apis.base.dim(x, nested=True)

Get the dimensions

Parameters
  • x the data frame to get the dimensions of
  • nested (bool, optional) whether x is a nested data frame
Returns (Any)

The dimensions

function

datar.apis.base.diag(x, nrow=None, ncol=None)

Get the diagonal of a matrix

Parameters
  • x the matrix to get the diagonal of
  • nrow (optional) the number of rows
  • ncol (optional) the number of columns
Returns (Any)

The diagonal of the matrix

function

datar.apis.base.duplicated(x, incomparables=None, from_last=False)

Get the duplicated values

Parameters
  • x the vector to get the duplicated values of
  • incomparables (optional) the incomparables
  • from_last (bool, optional) whether to search from the last
Returns (Any)

The duplicated values

function

datar.apis.base.intersect(x, y)

Get the intersection of two vectors

Parameters
  • x the first vector
  • y the second vector
Returns (Any)

The intersection of the two vectors

function

datar.apis.base.ncol(x, nested=True)

Get the number of columns

Parameters
  • x the data frame to get the number of columns of
  • nested (bool, optional) whether x is a nested data frame
Returns (Any)

The number of columns

function

datar.apis.base.nrow(x)

Get the number of rows

Parameters
  • x the data frame to get the number of rows of
Returns (Any)

The number of rows

function

datar.apis.base.proportions(x, margin=1)

Get the proportion table

Parameters
  • x the data frame to get the proportion table of
  • margin (int, optional) the margin
Returns (Any)

The proportion table

function

datar.apis.base.setdiff(x, y)

Get the difference of two vectors

Parameters
  • x the first vector
  • y the second vector
Returns (Any)

The difference of the two vectors

function

datar.apis.base.setequal(x, y)

Check if two vectors are equal

Parameters
  • x the first vector
  • y the second vector
Returns (Any)

Whether the two vectors are equal

function

datar.apis.base.unique(x)

Get the unique values

Parameters
  • x the vector to get the unique values of
Returns (Any)

The unique values

function

datar.apis.base.t(x)

Get the transpose

Parameters
  • x the matrix to get the transpose of
Returns (Any)

The transpose

function

datar.apis.base.union(x, y)

Get the union of two vectors

Parameters
  • x the first vector
  • y the second vector
Returns (Any)

The union of the two vectors

function

datar.apis.base.max_col(x, ties_method='random', nested=True)

Get the maximum column

Parameters
  • x the data frame to get the maximum column of
  • ties_method (str, optional) the ties method
  • nested (bool, optional) whether x is a nested data frame
Returns (Any)

The maximum column

function

datar.apis.base.complete_cases(x)

Get the complete cases

Parameters
  • x the data frame to get the complete cases of
Returns (Any)

The complete cases

function

datar.apis.base.head(x, n=6)

Get the first n rows

Parameters
  • x the data frame to get the first n rows of
  • n (int, optional) the number of rows to get
Returns (Any)

The first n rows

function

datar.apis.base.tail(x, n=6)

Get the last n rows

Parameters
  • x the data frame to get the last n rows of
  • n (int, optional) the number of rows to get
Returns (Any)

The last n rows

function

datar.apis.base.which(x)

Get the indices of the non-zero values

Parameters
  • x the vector to get the indices of the non-zero values of
Returns (Any)

The indices of the non-zero values

function

datar.apis.base.which_max(x)

Get the index of the maximum value

Parameters
  • x the vector to get the index of the maximum value of
Returns (Any)

The index of the maximum value

function

datar.apis.base.which_min(x)

Get the index of the minimum value

Parameters
  • x the vector to get the index of the minimum value of
Returns (Any)

The index of the minimum value