Checks if a file name can be found in a folder via partial string matching. Multiple types of output are supported.

find_file_name(string, output = "name", full = FALSE, ...)

Arguments

string

A character string, used for partial string matching.

output

The type of output to return. Options include...

  • 'index';

  • 'name';

  • 'logical';

  • 'vector'.

full

Logical; if TRUE returns the full path.

...

Additional arguments to the dir function.

Value

Either...

  • A single logical value, TRUE if any matching file names are found ('logical').

  • A logical vector, TRUE for all matching files in the vector of file names ('vector').

  • An integer vector giving the position of any matches in the vector of file names ('index').

  • A character vector with any matching file names, otherwise NULL ('name').

Examples

# Go to folder with html files for help pages
setwd(find.package("arfpam")[1])
setwd("html")

# Find help page for function 'every'
find_file_name("every")
#> NULL
find_file_name("every", output = "index")
#> integer(0)
find_file_name("every", output = "logical")
#> [1] FALSE
find_file_name("every", output = "vector")
#> [1] FALSE FALSE