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 (NOT your 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

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

Authentication requires you 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:

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")