Learn R Programming

rearrr (version 0.3.5)

median_index: Find index of interest for each vector

Description

lifecycle::badge("experimental")

Applies function to the indices of each vector in `...`.

These functions were created with create_n_fn().

Usage

median_index(..., negate = FALSE, round_fn = round)

quantile_index(..., prob, type = 7, negate = FALSE, round_fn = round)

Value

numeric vector with one element per supplied vector.

Arguments

...

Numeric vectors.

negate

Whether to negate the result. I.e. to multiply it with -1. (Logical)

round_fn

Function for rounding output. Rounding is done prior to negation.

E.g. round, floor, or ceiling.

prob

Probability in [0,1] for quantile().

type

Quantile algorithm to use. See quantile().

Author

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

Other n functions: create_n_fn()

Examples

Run this code
# \donttest{
# Attach packages
library(rearrr)

# Set seed
set.seed(1)

# Create three vectors
x <- runif(10)
y <- runif(15)
z <- runif(20)

median_index(x, y, z)
quantile_index(x, y, z, prob = 0.2)

# Negate result
median_index(x, y, z, negate = TRUE)
# }

Run the code above in your browser using DataLab