R/cleanCode.R

Defines functions cleanCode

cleanCode <- function(x) {

  codeDelimiters <- rock::opts$get("codeDelimiters");
  inductiveCodingHierarchyMarker <-
    rock::opts$get("inductiveCodingHierarchyMarker");

  x <-
    gsub(
      escapeRegexCharacterClass(codeDelimiters[1]),
      "",
      x
    );

  x <-
    gsub(
      escapeRegexCharacterClass(codeDelimiters[2]),
      "",
      x
    );

  x <- trimws(x);

  x <-
    gsub(
      paste0("^", inductiveCodingHierarchyMarker),
      "",
      x
    );

  x <-
    gsub(
      paste0(inductiveCodingHierarchyMarker, "$"),
      "",
      x
    );

  return(x);

}
gitlab-r-packages-mirror/rock documentation built on Dec. 3, 2024, 5:40 p.m.