Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

unwhich

Construct a logical vector with TRUE in specified positions.


Description

This function is basically an inverse of which.

Usage

unwhich(which, n)

Arguments

which

a numeric vector of indices to set to TRUE.

n

total length of the output vector.

Value

A logical vector of length n whose elements listed in which are set to TRUE, and whose other elements are set to FALSE.

Examples

x <- as.logical(rbinom(10,1,0.5))
stopifnot(all(x == unwhich(which(x), 10)))

statnet.common

Common R Scripts and Utilities Used by the Statnet Project Software

v4.4.1
GPL-3 + file LICENSE
Authors
Pavel N. Krivitsky [aut, cre] (<https://orcid.org/0000-0002-9101-3362>), Skye Bender-deMoll [ctb]
Initial release
2020-10-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.