R/is_filetype.R

Defines functions is_filetype

is_filetype <- function(x,
                        group=NULL){
  if(is.null(x)) return(FALSE)
  dict <- dict_filetype()
  matches <- lapply(dict, function(y){
    grepl(paste(paste0(gsub("\\.","\\.",y),"$"),collapse = "|"),x)
  })
  groups <- names(matches[unlist(matches)])
  if(is.null(group)){
    return(groups)
  } else {
    group <- tolower(group)
    if(!group %in% names(dict)){
      stopper(group,"is not a name in dict_filetype.")
    }
    return(group %in% groups)
  }
}
bschilder/scKirby documentation built on Oct. 2, 2024, 10:16 p.m.