Skip to content

Commit 36a8bea

Browse files
added remove lables fn to address build fail dpcy
1 parent 910e1a9 commit 36a8bea

18 files changed

Lines changed: 57 additions & 10 deletions

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export(make_short_long_nms_vec)
5050
export(make_std_fn_dmt_spine)
5151
export(make_undmtd_fns_dir_chr)
5252
export(read_fns)
53+
export(remove_lbls_from_df)
5354
export(remove_obj_type_from_nm)
5455
export(replace_abbr)
5556
export(rowbind_all_tbs_in_r4_obj)
@@ -137,6 +138,7 @@ importFrom(rlang,exec)
137138
importFrom(rlang,sym)
138139
importFrom(sinew,makeOxyFile)
139140
importFrom(sinew,makeOxygen)
141+
importFrom(stats,na.omit)
140142
importFrom(stats,setNames)
141143
importFrom(stringi,stri_locate_last_fixed)
142144
importFrom(stringi,stri_replace_first_regex)
@@ -151,7 +153,6 @@ importFrom(stringr,str_replace)
151153
importFrom(stringr,str_replace_all)
152154
importFrom(stringr,str_sub)
153155
importFrom(stringr,str_trim)
154-
importFrom(summarytools,unlabel)
155156
importFrom(testit,assert)
156157
importFrom(tibble,add_case)
157158
importFrom(tibble,is_tibble)

R/fn_add.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ add_indefartls_to_phrases <- function (abbreviated_phrase_1L_chr, abbreviations_
9494
#' @importFrom dplyr filter pull bind_rows arrange
9595
#' @importFrom rlang sym
9696
#' @importFrom Hmisc label
97-
#' @importFrom summarytools unlabel
9897
#' @keywords internal
9998
add_lups <- function (template_lup, new_lup, key_var_nm_1L_chr, priority_lup_for_dupls_1L_chr = "template")
10099
{
@@ -111,8 +110,8 @@ add_lups <- function (template_lup, new_lup, key_var_nm_1L_chr, priority_lup_for
111110
labels_chr <- Hmisc::label(new_lup) %>% unname()
112111
}
113112
if (!all(labels_chr %>% unique() == "")) {
114-
template_lup <- template_lup %>% summarytools::unlabel()
115-
new_lup <- new_lup %>% summarytools::unlabel()
113+
template_lup <- template_lup %>% remove_lbls_from_df()
114+
new_lup <- new_lup %>% remove_lbls_from_df()
116115
Hmisc::label(template_lup) <- as.list(labels_chr %>%
117116
unname())
118117
Hmisc::label(new_lup) <- as.list(labels_chr %>% unname())

R/fn_remove.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#' Remove lbls from
2+
#' @description remove_lbls_from_df() is a Remove function that edits an object, removing a specified element or elements. Specifically, this function implements an algorithm to remove lbls from data.frame. Function argument data_df specifies the object to be updated. The function returns Unlabelled data (a data.frame).
3+
#' @param data_df Data (a data.frame)
4+
#' @return Unlabelled data (a data.frame)
5+
#' @rdname remove_lbls_from_df
6+
#' @export
7+
#' @importFrom purrr reduce
8+
#' @keywords internal
9+
remove_lbls_from_df <- function (data_df)
10+
{
11+
unlabelled_data_df <- purrr::reduce(1:ncol(data_df), .init = data_df,
12+
~{
13+
class(.x[[.y]]) <- setdiff(class(.x[[.y]]), "labelled")
14+
attr(.x[[.y]], "label") <- NULL
15+
.x
16+
})
17+
return(unlabelled_data_df)
18+
}
119
#' Remove object type from name
220
#' @description remove_obj_type_from_nm() is a Remove function that edits an object, removing a specified element or elements. Specifically, this function implements an algorithm to remove object type from name. Function argument nms_chr specifies the object to be updated. Argument object_type_lup provides the object to be updated. The function returns Names (a character vector).
321
#' @param nms_chr Names (a character vector)

R/fn_write.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ write_inst_dir <- function (path_to_pkg_rt_1L_chr = getwd())
469469
#' @return NULL
470470
#' @rdname write_links_for_website
471471
#' @export
472-
472+
#' @importFrom stats na.omit
473473
write_links_for_website <- function (path_to_pkg_rt_1L_chr = getwd(), user_manual_url_1L_chr = NA_character_,
474474
developer_manual_url_1L_chr = NA_character_, project_website_url_1L_chr = NA_character_)
475475
{
@@ -496,7 +496,7 @@ write_links_for_website <- function (path_to_pkg_rt_1L_chr = getwd(), user_manua
496496
" - text: Project website", NA_character_),
497497
ifelse(!is.na(project_website_url_1L_chr), paste0(" href: ",
498498
project_website_url_1L_chr), NA_character_),
499-
txt_chr) %>% na.omit()
499+
txt_chr) %>% stats::na.omit()
500500
}, args_ls = list(user_manual_url_1L_chr = user_manual_url_1L_chr,
501501
developer_manual_url_1L_chr = developer_manual_url_1L_chr,
502502
project_website_url_1L_chr = project_website_url_1L_chr))

data-raw/fns/add.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ add_lups <- function(template_lup,
149149
labels_chr <- Hmisc::label(new_lup) %>% unname()
150150
}
151151
if(!all(labels_chr %>% unique() =="")){
152-
template_lup <- template_lup %>% summarytools::unlabel()
153-
new_lup <- new_lup %>% summarytools::unlabel()
152+
template_lup <- template_lup %>% remove_lbls_from_df()
153+
new_lup <- new_lup %>% remove_lbls_from_df()
154154
Hmisc::label(template_lup) <- as.list(labels_chr %>% unname())
155155
Hmisc::label(new_lup) <- as.list(labels_chr %>% unname())
156156
}

data-raw/fns/remove.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ remove_obj_type_from_nm <- function(nms_chr,
3838
return(names_chr)
3939

4040
}
41+
remove_lbls_from_df <- function(data_df){ # Adapted from: https://rdrr.io/github/dlindholm/doctoR/src/R/clear_labels.R
42+
unlabelled_data_df <- purrr::reduce(1:ncol(data_df),
43+
.init = data_df,
44+
~ {
45+
class(.x[[.y]]) <- setdiff(class(.x[[.y]]), 'labelled')
46+
attr(.x[[.y]],"label") <- NULL
47+
.x
48+
}
49+
)
50+
return(unlabelled_data_df)
51+
}

data-raw/fns/write.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ write_links_for_website <- function(path_to_pkg_rt_1L_chr = getwd(), # Needs dup
417417
ifelse(!is.na(developer_manual_url_1L_chr), paste0(" href: ", developer_manual_url_1L_chr), NA_character_),
418418
ifelse(!is.na(project_website_url_1L_chr), " - text: Project website", NA_character_),
419419
ifelse(!is.na(project_website_url_1L_chr), paste0(" href: ", project_website_url_1L_chr), NA_character_),
420-
txt_chr) %>% na.omit()
420+
txt_chr) %>% stats::na.omit()
421421
},
422422
args_ls = list(user_manual_url_1L_chr = user_manual_url_1L_chr,
423423
developer_manual_url_1L_chr = developer_manual_url_1L_chr,

data/fns_dmt_tb.rda

84 Bytes
Binary file not shown.

man/fns_dmt_tb.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/remove_lbls_from_df.Rd

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)