Kwker

R API reference

Every public function of the kwker R package, for vectors and data frames, with its parameters and results (Kwker 0.1.0).

kwk_sort Page

RInstall the kwker package (against the C package).
kwk_sort(x, decreasing = FALSE, na.last = NA)

Returns a sorted copy of a numeric vector, like base::sort.

Arguments

Returns

The sorted vector.

Example

RInstall the kwker package (against the C package).
kwk_sort(c(3, 1, 2))  # 1 2 3

Notes

kwk_order Page

RInstall the kwker package (against the C package).
kwk_order(x, decreasing = FALSE)

Returns the positions (1-based) that sort a numeric vector, like order(x). Equal values keep their input order.

Arguments

Returns

An integer vector of positions; NAs come last.

Example

RInstall the kwker package (against the C package).
kwk_order(c(30, 10, 20))  # 2 3 1

kwk_topk Page

RInstall the kwker package (against the C package).
kwk_topk(x, k, decreasing = FALSE)

Returns the k smallest (or largest) values in order, with their positions.

Arguments

Returns

List(values, indices); indices are 1-based, equal values go to the earlier position first, NAs last.

Example

RInstall the kwker package (against the C package).
kwk_topk(c(12, 7, 30, 18), 2, decreasing = TRUE)  # values 30 18, indices 3 4

kwk_isa Page

RInstall the kwker package (against the C package).
kwk_isa()

The engine in use: "avx512", "avx2" or "portable".

kwk_version Page

RInstall the kwker package (against the C package).
kwk_version()

The C library's version.

kwk_order_df Page

RInstall the kwker package (against the C package).
kwk_order_df(df, by = names(df), decreasing = FALSE, threads = 1L)

Returns the row order (1-based) that sorts a data frame by one or more key columns, like order(df$a, df$b, ..., method = "radix").

Arguments

Returns

An integer vector of row positions; NAs last, ties in row order.

Example

RInstall the kwker package (against the C package).
df <- data.frame(city = c(2, 1, 2), age = c(30, 40, 20))
kwk_order_df(df, by = c("city", "age"), decreasing = c(FALSE, TRUE))  # 2 1 3

Notes

kwk_sort_df Page

RInstall the kwker package (against the C package).
kwk_sort_df(df, by = names(df), decreasing = FALSE, threads = 1L)

Returns a data frame's rows sorted by key columns: df[kwk_order_df(df, by, decreasing), , drop = FALSE].

Arguments

Returns

The sorted data frame.

kwk_topk_df Page

RInstall the kwker package (against the C package).
kwk_topk_df(df, k, by = names(df), decreasing = FALSE)

Returns the first k rows of a data frame in key order without sorting all rows, like SQL ORDER BY ... LIMIT k.

Arguments

Returns

A data frame of up to k rows.