Learn R Programming

pedalfast.data (version 1.0.2)

onezero: 1/0 Flags

Description

Turns Yes/No variables into 1/0 integers

Usage

onezero(x)

Value

an integer vector

Arguments

x

a character vector

Details

The input is forced to lowercase and only the first character, the "y" or "n", is used to map to the 1/0 integer values. The function allows for "1" and "0" to be in the character vector as well.

Examples

Run this code

flag <- c("Y", "No", "NO", "no", "n", "YES", "Yes", "yEs", "1", "0")
onezero(flag)

Run the code above in your browser using DataLab