Skip to contents

Return the appropriate function for reading the specified path/extension

Usage

file_fn(x, write = FALSE)

Arguments

x

(character) The extension name or the path to the file

write

(logical) Return the writing function? Default FALSE to return the reading function

Value

(function)

Examples

file_fn("csv")
#> function (con = stdin(), n = -1L, ok = TRUE, warn = TRUE, encoding = "unknown", 
#>     skipNul = FALSE) 
#> {
#>     if (is.character(con)) {
#>         con <- file(con, "r")
#>         on.exit(close(con))
#>     }
#>     .Internal(readLines(con, n, ok, warn, encoding, skipNul))
#> }
#> <bytecode: 0x55c8974a77d0>
#> <environment: namespace:base>
file_fn("csv", write = TRUE)