/LookR

Primary LanguageR

Introduction

LookR is an R package that contains functions that interface with the Looker API programmatically—namely LookerSetup and LookerQuery.

Installation

  • Clone the LookR repo to your local machine.

  • Within the R console (install required packages first)

install.packages('RCurl')
install.packages('RJSONIO')
install.packages('digest')
install.packages('stringr')
install.packages('bitops')
install.packages('<path to directory containing tar>/LookR_1.0.tar.gz', repos = NULL, type = 'source')

Examples

library("LookR")

LookerSetup(
	token = "Jkz9GRYoIhyuJ4498FG89Iz",     	 	         # Not a real token
	secret = "v2+MNxMg1vdmijjYbtBhGDFEQSlAUEZd4xWd",         # Not a real secret
	host = "demo.looker.com", 
	port = 443
)

The function LookerSetup takes token, secret, host, and port as mandatory arguments. The function stores these values for use in LookerQuery.

df <- LookerQuery(
 	dictionary="thelook", 
 	query="orders", 
 	fields=c("orders.created_month", "orders.count"), 
 	filters=c("orders.created_date: 24 months", "orders.is_first_purchase: Yes")
)

head(df)

The function LookerQuery takes dictionary, query, and fields as mandatory arguments; filters, limit, and output are optional arguments. (Note: filters are passed as a vector of key-value pairs containing the dimension or measure name and the filter language, separated by a colon.) The output options supported are an R data frame or JSON object—the arguments are output="data.frame" and output="json", respectively.