The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

boxr: A high-level R interface for the box.com API

2021-01-19

Authentication

To use boxr, you will need to use a Box-app. You can think of a Box-app as the door through which the boxr functions will access Box.

tl;dr

If you have access to client_id and client_secret for a Box-app, you can use box_auth() to authenticate:

box_auth(client_id = "your_client_id", client_secret = "your_client_secret")

This will kick off a process that, all being well, will keep you authenticated for the rest of the R session. By saving this information to your .Renviron file, at your next R session you can use:

box_auth()

If you don’t have access to client_id and client_secret for a Box-app, read on.

More information

There are two different types of apps, as described in this overview article, or in these specific articles:

Basic operations

Functions that operate on Box files or directories (folders) have arguments: file_id or dir_id. You can use the box.com web interface to find these values. Although they look like numbers, it is useful to think of them as character strings.

Directories

Directories are identified using a dir_id:

We should note that the words “directory” and “folder” are used interchangeably, which can be confusing. Box uses the term “folder”, while the R world seems to favor the term “directory”. We assume that you have more familiarity with R than with Box; thus we also favor the term “directory” to name functions and arguments. We also recognize that we are not fully consistent in our implementation.

These functions all take (or return) a dir_id:

Cloud 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. The Box API does not support this directly, so boxr loops recursively through directory structures.

For these functions, be sure to pay attention to these arguments:

Disclaimer: Box is not a replacement for a VCS/remote-database, and familiar verbs are no guarantee of expected behavior! Do check the function documentation before jumping in.

Files

Files are identified using a file_id:

The main functions that operate on files are:

Advanced operations

The advanced operations have a similar philosophy to the basic operations, most of these functions take a file_id or a dir_id.

Interacting with Box files

Interacting with R Session

Using Box trash

Piping

boxr’s functions have been designed to be ‘pipeable’. Here’s a little example:

library(boxr)
library(dplyr)

# '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!

Reporting Bugs

If you find anything that looks like a bug while using it, please report it using a GitHub issue: https://github.com/r-box/boxr/issues.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.