Skip to contents

Suggests a alpha opacity to plot with as a function of the number of observation.

Usage

as_logical_index(index, n)

Arguments

index

A vector, typically a numeric row index of the data to coerce to a logical index.

n

Single numeric, the number of rows of the data use as a replicate return length.

Value

A logical index of length n.

Examples

library(cheem)

## Coerce a numeric index to logical
as_logical_index(c(1, 4:10, 15), nrow(mtcars))
#>  [1]  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE
#> [13] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

## Logical indexs are unchanged
as_logical_index(mtcars$mpg > 30, nrow(mtcars))
#>  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE
#> [25] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE