inst/source/R/is_path.R

#' Check Whether an Object Contains a Valid File System Path
#'
#' @param x The object.
#' @template return_boolean
#' @family file utilities
#' @export
#' @examples
#' is_path(tempdir())
#' path <- tempfile()
#' is_path(path)
#' touch(path)
#' is_path(path)
is_path <- function(x) {
    result <- is.character(x) && file.exists(x)
    return(result)
}

Try the fritools package in your browser

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

fritools documentation built on Nov. 19, 2023, 1:06 a.m.