Database Reference
In-Depth Information
- You Can Now Close This Page and Return to R. When you return to the R
window, you should see:
starting httpd help server … done
Waiting for authentication in browser…
Authentication complete.
f0_
1 17
If you see the result 17 , it means that bigrquery is working correctly.
Running Your First BigQuery Query from R
Now that you have bigrquery installed and can authenticate with BigQuery,
try running a simple query:
> query <- "SELECT corpus, max(corpus_date) as date,
count(*) as c
FROM [publicdata:samples.shakespeare]
GROUP BY corpus ORDER BY date asc"
> results <- query_exec("publicdata", "samples" ,
query, billing=billing_project)
The publicdata and samples arguments to the query_exec function
may be surprising. The first two positional arguments are the default project
and dataset for tables referenced in a query. As of the current version of
bigrquery, you need to specify these even if you use fully qualified table
names (for example, publicdata:samples.shakespeare ) in the query.
The advantage of specifying the defaults is that it makes your queries
simpler because you can specify only the table name, not the project or
dataset. To specify which project gets billed for the query, you should use
the billing argument. The authenticated user must be a member of the
project team to run queries, so you can't run queries as publicdata . If you
don't pass the billed project, BigQuery attributes the query to the project ID
passed as the first positional argument.
After the query completes, the entire results will be downloaded into an R
data frame. For queries returning large results, this can take a lot of time
and space. Even though this query only returns 42 rows and 3 columns, it is
Search WWH ::




Custom Search