Skip to contents

Retrieves and reads a file from the project's Google Drive folder. By default, the function attempts to determine the appropriate reading function based on the file's extension. However, you can specify a custom reading function if necessary.

Usage

cloud_drive_read(file, fun = NULL, ..., root = NULL)

Arguments

file

Path to a file relative to project folder root. Can contain only letters, digits, '-', '_', '.', spaces and '/' symbols.

fun

A custom reading function. If NULL (default), the appropriate reading function will be inferred based on the file's extension.

...

Additional arguments to pass to the reading function fun.

root

Google Drive ID or URL of the project root. This serves as the reference point for all relative paths. When left as NULL, the root is automatically derived from the cloudfs.drive field of the project's DESCRIPTION file.

Value

The content of the file read from Google Drive, with additional attributes containing metadata about the file.

Default reading functions

Here's how we identify a reading function based on file extension

Examples

if (FALSE) { # interactive()
# provided there are folders called "data" and "models" in the root of your
# project's main Google Drive folder and they contain the files mentioned
# below
cloud_drive_read("data/mtcars.csv")
cloud_drive_read("models/random_forest.rds")
cloud_drive_read("data/dm.sas7bdat", fun = haven::read_sas)
}