mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
fix: implement "with_labels" and added tests
This commit is contained in:
parent
342579c36f
commit
f928aee110
2 changed files with 150 additions and 13 deletions
29
R/helpers.R
29
R/helpers.R
|
|
@ -219,20 +219,23 @@ file_export <- function(data,
|
|||
#' head(5) |>
|
||||
#' str()
|
||||
default_parsing <- function(data) {
|
||||
name_labels <- lapply(data, \(.x) REDCapCAST::get_attr(.x, attr = "label"))
|
||||
# name_labels <- lapply(data, \(.x) REDCapCAST::get_attr(.x, attr = "label"))
|
||||
# browser()
|
||||
out <- data |>
|
||||
setNames(make.names(names(data), unique = TRUE)) |>
|
||||
## Temporary step to avoid nested list and crashing
|
||||
remove_nested_list() |>
|
||||
REDCapCAST::parse_data() |>
|
||||
REDCapCAST::as_factor() |>
|
||||
REDCapCAST::numchar2fct(numeric.threshold = 8,
|
||||
character.throshold = 10) |>
|
||||
REDCapCAST::as_logical() |>
|
||||
REDCapCAST::fct_drop()
|
||||
|
||||
set_column_label(out, setNames(name_labels, names(out)), overwrite = FALSE)
|
||||
with_labels(data,{
|
||||
data |>
|
||||
setNames(make.names(names(data), unique = TRUE)) |>
|
||||
## Temporary step to avoid nested list and crashing
|
||||
remove_nested_list() |>
|
||||
REDCapCAST::parse_data() |>
|
||||
REDCapCAST::as_factor() |>
|
||||
REDCapCAST::numchar2fct(numeric.threshold = 8,
|
||||
character.throshold = 10) |>
|
||||
REDCapCAST::as_logical() |>
|
||||
REDCapCAST::fct_drop()
|
||||
})
|
||||
# out <-
|
||||
#
|
||||
# set_column_label(out, setNames(name_labels, names(out)), overwrite = FALSE)
|
||||
|
||||
# purrr::map2(
|
||||
# out,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue