cleaning and fixes for a minor release

This commit is contained in:
Andreas Gammelgaard Damsbo 2025-01-29 10:04:38 +01:00
commit 8d20901636
No known key found for this signature in database
29 changed files with 122 additions and 41 deletions

View file

@ -97,7 +97,10 @@ focused_metadata <- function(metadata, vars_in_data) {
#' @return vector or data frame, same format as input
#' @export
#'
#' @examples
#' "Research!, ne:ws? and c;l-.ls" |> clean_redcap_name()
clean_redcap_name <- function(x) {
gsub("[,.;:?!@]","",
gsub(
" ", "_",
gsub(
@ -108,6 +111,7 @@ clean_redcap_name <- function(x) {
)
)
)
)
}
@ -518,3 +522,22 @@ dummy_fun <- function(...){
gtsummary::add_difference()
)
}
#' Cut string to desired length
#'
#' @param data data
#' @param l length
#'
#' @returns character string of length l
#' @export
#'
#' @examples
#' "length" |> cut_string_length(l=3)
cut_string_length <- function(data,l=100){
if (nchar(data)>=l){
substr(data,1,l)
} else {
data
}
}