bigrquery (version 0.3.0)

src_bigquery: A bigquery data source.

Description

Use src_bigquery to connect to an existing bigquery dataset, and tbl to connect to tables within that database.

Usage

src_bigquery(project, dataset, billing = project, max_pages = 10)

Arguments

project

project id or name

dataset

dataset name

billing

billing project, if different to project

max_pages

(IGNORED) max pages returned by a query

Examples

Run this code

library(dplyr)

# To run this example, replace billing with the id of one of your projects
# set up for billing
pd <- src_bigquery("publicdata", "samples", billing = "887175176791")
pd %>% tbl("shakespeare")

# With bigquery data, it's always a good idea to start by selecting
# only the variables you're interested in - this reduces the amount of
# data that needs to be scanned and hence decreases costs
natality <- pd %>%
  tbl("natality") %>%
  select(year:day, state, child_race, weight_pounds)
year_weights <- natality %>%
  group_by(year) %>%
  summarise(weight = mean(weight_pounds), n = n()) %>%
  arrange(year) %>%
  collect()
plot(year_weights$year, year_weights$weight, type = "b")

Run the code above in your browser using DataLab