R/check_for_file_extension.R

Defines functions check_for_file_extension

Documented in check_for_file_extension

#' check_for_file_extension: a function to make our package 'smart' enough to
#' handle .rds file extensions
#' @param path A string specifying a file path that ends in a file name, e.g. "~/dir/my_file.rds"
#'
#' @return a string with a filepath *without* an extension, e.g. "~/dir/my_file"
#' @keywords internal

check_for_file_extension <- function(path){
  if (grepl('.rds', path)) {
    path <- unlist(strsplit(path, split = ".rds", fixed = TRUE))

  }

  if (grepl('.bk', path)) {
    path <- unlist(strsplit(path, split = ".bk", fixed = TRUE))
  }

  return(path)

}

Try the plmmr package in your browser

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

plmmr documentation built on April 4, 2025, 12:19 a.m.