R/compsplit.R

Defines functions compsplit

compsplit <- function(x, split) {
  
  if (split %in% .special.characters)
    split <- paste("\\", split, sep = "")

  res <- strsplit(x, split)

  if (is.list(res)) {
    withspace <- any(unlist(lapply(res, grepl, pattern = "^\\s+|\\s+$")))
    res <- lapply(res, gsub, pattern = "^\\s+|\\s+$", replacement = "")
  }
  else {
    withspace <- any(grepl("^\\s+|\\s+$", "", res))
    res <- gsub("^\\s+|\\s+$", "", res)
  }
  ##
  attr(res, "withspace") <- withspace
  
  res
}

Try the netmeta package in your browser

Any scripts or data that you put into this service are public.

netmeta documentation built on June 23, 2024, 9:06 a.m.