box_read
will download a file specified by file_id
, and
attempt to read it into memory as an R object. This can be useful, for
example, to read in a .csv
file as a data.frame()
.
Converting a file to an R object is by default handled by
rio::import()
function. The only
modification of it's behavior is that json files are not neccesarily
coerced to data.frame
s, but can used to store list
data, too.
In addtion, more specific read functions are provided:
box_read_csv
- Reads remote .csv
files as
data.frame()
s (via read.csv()
)
box_read_tsv
- Reads remote .tsv
files as
data.frame()
s (via read.delim()
)
box_read_json
- Reads remote .json
files as
list()
s (via jsonlite::toJSON()
)
box_read_excel
- Reads remote Microsoft Excel files
as data.frame()
s (via readxl::read_excel()
)
box_read(file_id, type = NULL, version_id = NULL, version_no = NULL, read_fun = rio::import, fread = FALSE, ...) box_read_csv(file_id, ...) box_read_tsv(file_id, ...) box_read_json(file_id, ...) box_read_excel(file_id, ...)
file_id | The box.com id for the file that you'd like to download |
---|---|
type | MIME type (aka internet media type) used to override the content type returned by the server. See Wikipedia for a list of common types |
version_id | If downloading an older version, the |
version_no | The version of the file you'd like to download (starting at 1) |
read_fun | The function used to read the data into R. Defaults to
|
fread | Should the function |
... | Passed to as additional parameters to read_fun |
box_dl()
for saving files to disk
box_save()
for working with R workspaces
box_source()
for working with R code.