mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 05:07:30 +02:00
as_factor functions to preserve attributes
This commit is contained in:
parent
42efec437a
commit
c3b54b0860
8 changed files with 378 additions and 104 deletions
25
man/named_levels.Rd
Normal file
25
man/named_levels.Rd
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/as_factor.R
|
||||
\name{named_levels}
|
||||
\alias{named_levels}
|
||||
\title{Get named vector of factor levels and values}
|
||||
\usage{
|
||||
named_levels(data, label = "labels", na.label = NULL, na.value = 99)
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{factor}
|
||||
|
||||
\item{label}{character string of attribute with named vector of factor labels}
|
||||
}
|
||||
\value{
|
||||
named vector
|
||||
}
|
||||
\description{
|
||||
Get named vector of factor levels and values
|
||||
}
|
||||
\examples{
|
||||
structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10),
|
||||
class = "haven_labelled"
|
||||
) |> as_factor() |> named_levels()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue