is.binary: Binary Vectors

Description Usage Arguments Value Examples

View source: R/is.binary.R

Description

is.binary is used to test if a vector is of binary type, i.e. if a vector contains only 0 and/or 1 values.

Usage

1

Arguments

x

a vector to be tested.

Value

is.binary returns TRUE or FALSE depending on whether a vector is of binary type or not.

Examples

1
2
3
4
x1 <- runif(100, 0, 1)
x2 <- ifelse(x1 < 0.5, 1, 0)
is.binary(x1)
is.binary(x2)

Example output

Loading required package: tidyverse
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.2purrr   0.3.4tibble  3.0.4dplyr   1.0.2tidyr   1.1.2stringr 1.4.0readr   1.4.0forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()dplyr::lag()    masks stats::lag()
[1] FALSE
[1] TRUE

WinRatio documentation built on Nov. 23, 2020, 9:06 a.m.