Easily talk to Google's 'BigQuery' database from R.
The bigrquery packages provides an R interface to Google BigQuery. It makes it easy to retrieve metadata about your projects, datasets, tables and jobs, and provides a convenient wrapper for working with bigquery from R.
The current bigrquery release can be installed from CRAN:
The newest development release can be installed from github:
The first time you use bigrquery in a session, it will ask you to
authorize bigrquery in
the browser. This gives bigrquery the credentials to access data on your
behalf. By default, bigrquery picks up httr's
policy of caching per-working-directory credentials in
bigrquery requests permission to modify your data; in general, the
only data created or modified by
bigrquery are the temporary tables created
as query results, unless you explicitly modify your own data (say by calling
If you just want to play around with the bigquery API, it's easiest to start with the Google's free sample data. To do that, you'll also need to create your own project for billing purposes. If you're just playing around, it's unlikely that you'll go over the 10,000 request/day free limit, but google still needs a project that it can bill (you don't even need to provide a credit card).
To create a project:
Project Numberto identify your project with
bigrquery. (You can also use the project number, though it's harder to remember.)
To run your first query:
library(bigrquery)project <- "fantastic-voyage-389" # put your project ID heresql <- "SELECT year, month, day, weight_pounds FROM [publicdata:samples.natality] LIMIT 5"query_exec(sql, project = project)
set_service_token() allows you to use OAuth service token instead of
^ is correctly translated to
Provide full DBI compliant interface (@krlmlr).
Backend now translates
IF (@realAkhmed, #53).
Compatiable with latest httr.
Computation of the SQL data type that corresponds to a given R object is now more robust against unknown classes. (#95, @krlmlr)
A data frame with full schema information is returned for zero-row results. (#88, @krlmlr)
exists_table(). (#91, @krlmlr)
insert_upload_job(). (#92, @krlmlr)
bigrquery.quiet. (#89, @krlmlr)
format_table(). (#81, @krlmlr)
list_tabledata_iter() that allows fetching a table in chunks of
varying size. (#77, #87, @krlmlr)
Add support for API keys via the
BIGRQUERY_API_KEY environment variable.