mixpanelJQLQuery {RMixpanel}R Documentation

Query the Mixpanel JQL API

Description

This method performs a JQL Query with some custom script as parameter. The query string can be given either as character vector or saved into a file and passed via file name.

Usage

mixpanelJQLQuery(account, jqlString, jqlScripts, paths=".", columnNames, toNumeric=c())

Arguments

account

A mixpanel account, as defined in mixpanelCreateAccount.

jqlString

JQL script as string.

jqlScripts

List of JQL script file names.

paths

Paths to search JS files.

columnNames

Column names for the resulting data.frame. Optional.

toNumeric

Column indices which should be converted to numeric. Optional.

Value

If data==TRUE, the method returns the response of the API request (raw character vector). Otherwise nothing is returned.

Author(s)

Meinhard Ploner

References

https://mixpanel.com/help/reference/jql

Examples

## Not run: 
## Fill in here the API token, key and secret as found on 
## www.mixpanel.com - Account -> Projects. 
account = mixpanelCreateAccount("ProjectName",
                                token="c12g3...",
                                secret="168e7e...", 
                                key="543c55...")
                                
## Simple query: number of events for each 'distinct_id'.
jqlQuery <- '
function main() {
  return Events({
    from_date: "2016-01-01",
    to_date: "2016-12-31"
  })
  .groupByUser(mixpanel.reducer.count())
}'

res <- mixpanelJQLQuery(account, jqlQuery,
                        columnNames=c("distinctID", "Count"), toNumeric=2)
hist(res$Count)

## End(Not run)

[Package RMixpanel version 0.7-1 Index]