mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 13:17:30 +02:00
Deploying to gh-pages from @ agdamsbo/REDCapCAST@db75c3313e 🚀
This commit is contained in:
parent
bc2e23a272
commit
0b30252598
171 changed files with 7009 additions and 602 deletions
62
reference/named_levels.md
Normal file
62
reference/named_levels.md
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# Get named vector of factor levels and values
|
||||
|
||||
Get named vector of factor levels and values
|
||||
|
||||
## Usage
|
||||
|
||||
``` r
|
||||
named_levels(
|
||||
data,
|
||||
label = "labels",
|
||||
na.label = NULL,
|
||||
na.value = 99,
|
||||
sort.numeric = TRUE
|
||||
)
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
||||
- data:
|
||||
|
||||
factor
|
||||
|
||||
- label:
|
||||
|
||||
character string of attribute with named vector of factor labels
|
||||
|
||||
- na.label:
|
||||
|
||||
character string to refactor NA values. Default is NULL.
|
||||
|
||||
- na.value:
|
||||
|
||||
new value for NA strings. Ignored if na.label is NULL. Default is 99.
|
||||
|
||||
- sort.numeric:
|
||||
|
||||
sort factor levels if levels are numeric. Default is TRUE
|
||||
|
||||
## Value
|
||||
|
||||
named vector
|
||||
|
||||
## Examples
|
||||
|
||||
``` r
|
||||
structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10),
|
||||
class = "haven_labelled"
|
||||
) |>
|
||||
as_factor() |>
|
||||
named_levels()
|
||||
#> 1 2 3 Refused Unknown
|
||||
#> 1 2 3 10 9
|
||||
structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10),
|
||||
class = "labelled"
|
||||
) |>
|
||||
as_factor() |>
|
||||
named_levels()
|
||||
#> 1 2 3 Refused Unknown
|
||||
#> 1 2 3 10 9
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue