Skip to contents

Reads a file from the Downloads directory and returns it as a data frame. The file type is automatically detected from the extension.

Usage

readDownload(file, ..., output = c("data.frame", "tibble"))

Arguments

file

character string specifying the name of the file.

...

additional arguments passed to the underlying read function, e.g. sheet for Excel files or delim for text files.

output

character, either "data.frame" (default) or "tibble", determining the class of the returned object. Conversion to data.frame is done by toBaseR(). The argument can be abbreviated. Note that it must be given as a named argument, as it follows the dots.

Value

a data.frame or a tibble, according to output.

Details

This is a convenience wrapper combining findDownload() with common file readers:

For the readr-based formats the column specification message is suppressed by default; supply show_col_types = TRUE to restore it. By default, the result is converted to a base R data.frame.

Examples

if (FALSE) { # \dontrun{
# cannot be run automatically: reads the personal Downloads
# directory of the user, where no such files exist

# read an Excel file
readDownload("data.xlsx")

# read a CSV file
readDownload("data.csv")

# keep the tibble output
readDownload("data.csv", output = "tibble")
} # }