Learn R Programming

cheapr (version 0.9.8)

setdiff_: Extra utilities

Description

Extra utilities

Usage

setdiff_(x, y, dups = TRUE)

intersect_(x, y, dups = TRUE)

cut_numeric( x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3L, ordered_result = FALSE, ... )

# S3 method for integer64 cut(x, ...)

x %in_% table

x %!in_% table

enframe_(x, name = "name", value = "value")

deframe_(x)

sample_(x, size = vector_length(x), replace = FALSE, prob = NULL)

val_insert(x, value, n = NULL, prop = NULL)

na_insert(x, n = NULL, prop = NULL)

vector_length(x)

Value

enframe()_ converts a vector to a data frame.

deframe()_ converts a 1-2 column data frame to a vector.

intersect_() returns a vector of common values between x and y.

setdiff_() returns a vector of values in x but not y.

cut_numeric() places values of a numeric vector into buckets, defined through the breaks argument and returns a factor unless labels = FALSE, in which case an integer vector of break indices is returned.

%in_% and %!in_% both return a logical vector signifying if the values of x exist or don't exist in table respectively.

sample_() is an alternative to sample() that natively samples data frame rows through sset(). It also does not have a special case when length(x) is 1.

val_insert inserts scalar values randomly into your vector. Useful for replacing lots of data with a single value.

na_insert inserts NA values randomly into your vector. Useful for generating missing data.

vector_length behaves mostly like NROW() except for matrices in which it matches length().

Arguments

x

A vector or data frame.

y

A vector or data frame.

dups

Should duplicates be kept? Default is TRUE.

breaks

See ?cut.

labels

See ?cut.

include.lowest

See ?cut.

right

See ?cut.

dig.lab

See ?cut.

ordered_result

See ?cut.

...

Further arguments passed onto cut or set.seed.

table

See ?collapse::fmatch

name

The column name to assign the names of a vector.

value

The column name to assign the values of a vector.

size

See ?sample.

replace

See ?sample.

prob

See ?sample.

n

Number of scalar values (or NA) to insert randomly into your vector.

prop

Proportion of scalar values (or NA) values to insert randomly into your vector.

Details

intersect_() and setdiff_() are faster and more efficient alternatives to intersect() and setdiff() respectively.
enframe_() and deframe_() are faster alternatives to tibble::enframe() and tibble::deframe() respectively.
cut_numeric() is a faster and more efficient alternative to cut.default().