R/C_hss_space.R

Defines functions C_hss_space

Documented in C_hss_space

#' Remove extra space(s) from text
#'
#' This function is part of the recode pipeline and is necessary for the effective use of
#' the subsequent functions hss_gen_prep and hss_rewrite. The goal of this function is to eliminate
#' spaces at the start of a text string. This function accounts for potential spaces added to Arabic
#' or English text.
#'
#' @param dat df that needs recoding
#'
#' @return a df without spaces in the beginning of text strings
#'
#' @rdname C_hss_space
#' @export
#'
C_hss_space <- function(dat){
  spaced_dat <- dat[ , grep("_oth_what", colnames(dat))]
  var_names_space <- as.list(colnames(spaced_dat))

  for(i in var_names_space){
    dat[[i]] <- stringr::str_trim(dat[[i]], side = c("both", "left", "right"))}
  return(dat)
}
RenRMT/hsstools documentation built on April 14, 2025, 7:10 p.m.