# Basic usage
flg <- defined(c(TRUE, FALSE, TRUE), label = "Flag")
as_logical(flg)
# Metadata preserved by default
attr(as_logical(flg), "label")
# Stripping metadata
as_logical(flg, strip_attributes = TRUE)
# Base R coercion also works (via S3 method dispatch)
as.logical(flg)
Run the code above in your browser using DataLab