Google Compute Engine (GCE) lets you create and run virtual machines on Google infrastructure. See the general Google documentation here.

Before you begin, you will need to set up a Cloud Platform project, and enable billing by adding a credit card.

A quickstart guide to using GCE is available here for making your first VM via the web interface, if you are not familiar with GCE then its best to start there.

Pricing is available here.

For googleComputeEngineR you will need:

  • Your project ID e.g. my-project-name
  • Your preferred geographical zone to launch VMs e.g. europe-west1-a
  • [Recommended] A Service account key json file, downloaded from the API Manager > Credentials > Create credentials > Service account key > Key type = JSON
  • [Optional] If not using service account key, you will need the client-id and client-secret for your project.

Setup video guide

A video guide to setup and launching an RStudio server has been kindly created by Donal Phipps and is available at this link.


Auto-authentication via .Renviron

The best way to handle authentication is to set environment arguments with your setup details.

These can be set in an .Renviron file located on your computer home directory - R will look in this file upon startup. Read more via ?Startup

The easiest way to find the right home directory is within RStudio, to click on the Home button in RStudio’s file explorer. Create a file via File > New file > Text File, save and call it .Renviron

My .Renviron file looks a bit like this:


The GCE_AUTH_FILE points to the file location of the service account JSON file taken from your Google Project. The other arguments set the default project and zone.

This file will then used for authentication when you load the library:

## GCE_AUTH_FILE set so auto-authentication
> library(googleComputeEngineR)
Successfully authenticated via /Users/mark/auth.json
Set default project name to 'mark-xxxxx'
Set default zone to 'europe-west1-a'

## no need for gce_auth() and will call default project
> gce_get_project()
[1] "compute#project"

[1] "43534234234324324"

[1] "2015-05-08T15:22:38.416-07:00"

[1] "mark-xxxxx"


Other authentication methods

If you can’t use an .Renviron you can set environment files within the script via Sys.setenv:

Sys.setenv("GCE_AUTH_FILE" = "/fullpath/to/auth.json")