mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2026-06-19 05:07:30 +02:00
a new helper function has been introduced to help matching form names when special characters are in use.
This commit is contained in:
parent
4847094f2c
commit
563c864091
3 changed files with 25 additions and 7 deletions
19
R/utils.r
19
R/utils.r
|
|
@ -83,9 +83,24 @@ focused_metadata <- function(metadata, vars_in_data) {
|
|||
|
||||
}
|
||||
|
||||
#' clean_redcap_name
|
||||
#' @description
|
||||
#' Stepwise removal on non-alphanumeric characters, trailing white space,
|
||||
#' substitutes spaces for underscores and converts to lower case.
|
||||
#' Trying to make up for different naming conventions.
|
||||
#'
|
||||
#' @param x vector or data frame for cleaning
|
||||
#'
|
||||
#' @return vector or data frame, same format as input
|
||||
#' @export
|
||||
#'
|
||||
clean_redcap_name <- function(x){
|
||||
|
||||
|
||||
# function to convert the list of dataframes
|
||||
gsub(" ", "_",
|
||||
gsub("[' ']$","",
|
||||
gsub("[^a-z0-9' '_]", "",
|
||||
tolower(x)
|
||||
)))}
|
||||
|
||||
|
||||
#' Sanitize list of data frames
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue