Git Product home page Git Product logo

rairtable's Introduction

rairtable

Efficient CRUD interface to the Airtable API

R-CMD-check CRAN_Status_Badge metacran downloads

rairtable is an efficient, Tidyverse-friendly interface to Airtable API intended to simplify the integration of Airtable into data science workflows. Other R packages exist for this purpose, but rairtable offers the following advantages:

  • Create, update, and delete Airtable records in batches of up to 10 at a time
  • Optional parallelization of JSON encoding for large tables
  • Tidyverse conscious development, facilitating Airtable as an endpoint for dplyr pipelines
  • Support for Airtable views
  • Convenient interface for setting and updating Airtable API keys

INSTALLATION

For the stable CRAN release, install using install.packages('rairtable'). For the development version of the package, use remotes::install_giuthub('matthewjrogers/rairtable')


USAGE

Get and set your API key

Generate an Airtable API key from your Airtable account page and pass the result to set_airtable_api_key('MY_KEY_HERE'). If you would like to store the key in your .Renviron file for use in the future, set set_airtable_api_key('MY_KEY_HERE', install = TRUE).

Connect to a table

table <- airtable('TABLE_NAME', 'BASE_ID')

view <- airtable('TABLE_NAME', 'BASE_ID', view = 'VIEW_NAME')

rairtable::airtable() creates an airtable object that is used in a similar fashion to a database connection. The resulting object is then passed to other rairtable functions.

Read a table

airtable_data <- read_airtable(airtable_object, id_to_col = TRUE, max_rows = 50000)

By default, read_airtable() will read all rows in the chosen table and store Airtable records IDs in a column named airtable_record_id. Optionally, airtable record IDs can be stored as row names for convenience.

Row names are bad practice in most cases. For this application, they offer the advantage of being sticky through most subset and transform operations which allows us to retain the record ID by default. Some operations will destroy row names (e.g. the use of dplyr::arrange()). For these reasons, the default behavior is to store the record IDs in a column. Airtable record IDs are necessary for update and delete operations, but otherwise can be ignored.

Workflow

rairtable is intended to slot into existing data processing workflows.

table <- airtable('mtcars', 'appXXXXXXXXXXXXXX')

cars_airtable <- read_airtable(table)

# change units of qsec to minutes
cars_airtable <- cars_airtable %>%
  mutate(qsec = qsec/60) %>%
  update_records(table, columns = qsec)

# remove records where mpg is less than 12
removed_ids <- cars_airtable %>%
  filter(mpg < 12) %>%
  delete_records(table)

cars_airtable %>%
  filter(!airtable_id %in% removed_ids)


rairtable's People

Contributors

matthewjrogers avatar roboton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.