This article walks through the setup required for "Calculating Customer Lifetime Value using BigQuery Export for Google Analytics".
The following steps only need to be executed once per Compute Engine instance. The setup time is a few minutes.
The following commands install R and rpy2:
%%bash
apt-get update
apt-get install r-base-dev -y
apt-get install python-rpy2 -y
Now load rpy2:
%load_ext rpy2.ipython
This command installs the BTYD package in R:
%%R
install.packages('BTYD', repos='http://cran.us.r-project.org', dependencies=TRUE)
Everything needed for "Calculating Customer Lifetime Value using BigQuery Export for Google Analytics" is now installed. In other notebooks, you will still need to load rpy2 and the BTYD package using the following:
%load_ext rpy2.ipython
%%R
library(BTYD)