mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 05:07:30 +02:00
cleaning and fixes for a minor release
This commit is contained in:
parent
7d82eeebd4
commit
8d20901636
29 changed files with 122 additions and 41 deletions
23
R/utils.r
23
R/utils.r
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue