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
51
reference/fct2num.md
Normal file
51
reference/fct2num.md
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# Allows conversion of factor to numeric values preserving original levels
|
||||
|
||||
Allows conversion of factor to numeric values preserving original levels
|
||||
|
||||
## Usage
|
||||
|
||||
``` r
|
||||
fct2num(data)
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
||||
- data:
|
||||
|
||||
vector
|
||||
|
||||
## Value
|
||||
|
||||
numeric vector
|
||||
|
||||
## Examples
|
||||
|
||||
``` r
|
||||
c(1, 4, 3, "A", 7, 8, 1) |>
|
||||
as_factor() |>
|
||||
fct2num()
|
||||
#> [1] 1 2 3 4 5 6 1
|
||||
|
||||
structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10),
|
||||
class = "haven_labelled"
|
||||
) |>
|
||||
as_factor() |>
|
||||
fct2num()
|
||||
#> [1] 1 2 3 2 10 9
|
||||
|
||||
structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10),
|
||||
class = "labelled"
|
||||
) |>
|
||||
as_factor() |>
|
||||
fct2num()
|
||||
#> [1] 1 2 3 2 10 9
|
||||
|
||||
structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10)
|
||||
) |>
|
||||
as_factor() |>
|
||||
fct2num()
|
||||
#> [1] 1 2 3 2 NA NA
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue