vignettes/boxr.Rmd
boxr.Rmd
Aside from file upload/download, boxr provides functions which mirror base R operations for local files.
box_dl(file_id)
and box_ul(file = 'path/to/file')
to download and upload files respectivelybox_load()
/box_save()
for remote R workspacesbox_read()
to read files straight into R (e.g. .csv or .xlsx files as data.frames
)box_setwd()
/box_getwd()
to get/set a default box folderbox_source()
to read and execute remote codebox_write()
to write R objects the remotely hosted filesbox_search()
to query files stored on box.combox_add_description()
add text descriptions to your files on box.comCloud storage services can complement version control systems for code, which aren’t well suited to large binary files (e.g. databases, .RData, or heaps of pdfs). box explicitly versions binary files, keeping old ones, and making it easy fall back to an older copy.
boxr provides git style facilities to upload, download, and synchronize the contents of entire local and remote directories. At the time of writing, the box.com API does not support this directly, and so boxr recursively loops through directory structures.
box_push
will update the remote directory with new/changed local filesbox_fetch
will update the local directory with new/changed remote filesThese functions all have overwrite
and delete
parameters, which are set to FALSE
by default.
Disclaimer: box.com is no replacement for a VCS/remote-database, and familiar verbs are no guarantee of expected behavior! Do check the function documentation before jumping in.
boxr’s functions have been designed to be ‘pipable’. Here’s a little example:
library(boxr)
library(dplyr)
library(magrittr)
# 'nycflights13.json' is the same as nycflights13::flights, if you want to
# follow along at home
box_auth()
box_search("nycflights13.json") %>% # Find a remote file
box_read() %>% # Download it as a data.frame
group_by(origin, dest, month) %>% # Do some, er, cutting edge
summarise(mu = mean(arr_delay), n = n()) %>% # analysis with dplyr!
box_write("delay_summary.xlsx") %>% # Convert to .xlsx, upload
box_add_description("Check out these averages!") # Add a description to your file!
boxr is by default rather verbose, printing status to the console with cat
. This is ‘rude’ package behaviour, and may cause unwanted output if used in conjunction with the excellent knitr
package.
To supress messages produced using cat
, set boxr’s verbose option with:
boxr aims to expedite data analysis/communication/distribution. Other ways to manipulate a box.com account include:
boxr is a realtively new package. If you find anything that looks like a bug while using it, please report it!
The best way to do this is via a GitHub issue, at: https://github.com/brendan-R/boxr/issues