fetch_hook_read: Hook to fetch a resource from a file.

View source: R/driver_external.R

fetch_hook_readR Documentation

Hook to fetch a resource from a file.

Description

Hook to fetch a resource from a file, for use with driver_external. We take two functions as arguments: the first converts a key/namespace pair into a filename, and the second reads from that filename. Because many R functions support reading from URLs fetch_hook_read can be used to read from remote resources.

Usage

fetch_hook_read(fpath, fread)

Arguments

fpath

Function to convert ⁠key, namespace⁠ into a file path

fread

Function for converting filename into an R object

Details

For more information about using this, see storr_external (this can be used as a fetch_hook argument) and the vignette: vignette("external")

Examples

hook <- fetch_hook_read(
    function(key, namespace) paste0(key, ".csv"),
    function(filename) read.csv(filename, stringsAsFactors = FALSE))

storr documentation built on April 15, 2025, 5:09 p.m.