looker/lookr

Name: lookr

Owner: looker

Description: An R library for the Looker API (3.0)

Created: 2015-09-09 04:03:27.0

Updated: 2017-07-31 17:23:14.0

Pushed: 2017-02-23 21:07:21.0

Homepage: null

Size: 3828

Language: R

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

LookR

Overview

LookR is an open-source R library that provides the user an interface from the R Console or command line to the Looker API (3.0). The API methods are determined dynamically by a Swagger JSON file available on a given Looker instance. All client methods are written in Java and called from R using the rJava library.

OSX Installation

The LookR library is not distributed on CRAN; instead, one must build directly from source. Run the following commands in the R console or command-line client.

all.packages("devtools")
ary("devtools")
all_github("looker/lookr")  # to get upstream changes, run this command periodically
Ubuntu Installation
Preliminaries

Note: I am testing this in an virtual environment that's running Ubuntu 14.04. Make sure Apt is installed. Open up a terminal window and type

apt

You should see something like this:

image

If not, try installing Apt referencing Step 1 from here.

Java Setup

Determine which Java version you have running (LookR has only been tested on Java 7 and 8):

 -version

If you don't have Java installed or you think it might be best to upgrade, run the following commands:

 apt-get install python-software-properties

 add-apt-repository ppa:webupd8team/java

 apt-get update

 apt-get install oracle-java8-installer

Once you have a JRE and Java SDK installed, confirm that the necessary Java environmental variables are set:

 $JAVA_HOME

If there are no results, run:

rt JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")

rt PATH=$PATH:$JAVA_HOME/bin

Create a Java config file for R:

 vi /etc/ld.so.conf.d/java.conf

Then paste /usr/lib/jvm/java-8-oracle/jre/lib/amd64 and /usr/lib/jvm/java-8-oracle/jre/lib/amd64/server into that file and save it.

Set the shared library variable:

rt LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/lib/amd64/server

Set up R's Java config file:

 R CMD javareconf
R Setup

Note that LookR requires R version 3.2 or later.

Install R base:

 apt-get -y install r-base

Install rJava:

 apt-get install r-cran-rjava

Install RJSONIO:

sudo apt-get install r-cran-RJSONIO

Install curl utilities for future devtools support:

 apt-get -y build-dep libcurl4-gnutls-dev

 apt-get -y install libcurl4-gnutls-dev

Enter the R command-line client:


Install devtools:

all.packages("devtools")

Install LookR:

ary("devtools")
all_github("looker/lookr")
Usage
eliminaires #
ary("devtools")
ary("LookR")

tting up the client and authenticating (id and secret are available on your Looker instance)
er_setup(   id = "myapi3id",
            secret = "myapi3secret",
            api_path = "https://mylookerendpoint.com:19999/api/3.0"


nning a Look by its look_id
ook <- run_look(2039)

nning an inline query by providing query components (note: model, view, and fields are required parameters)
nline_query <- run_inline_query(model = "thelook",
                                view = "orders", # refers to the base view, or the name of the explore from which you are querying from
                                fields = c("orders.count", "orders.created_month")
                                filters = list(c("orders.created_month", "90 days"), c("orders.status", "complete"))

Contributing
TODO
  1. tests;
  2. push as many R functions as possible into Java.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.