Learn R Programming

Rlabkey (version 2.1.121)

makeFilter: Builds filters to be used in labkey.selectRows and getRows

Description

This function takes inputs of column name, filter value and filter operator and returns an array of filters to be used in labkey.selectRows and getRows.

Usage

makeFilter(...)

Arguments

...
Arguments in c("colname","operator","value") form, used to create a filter.

Value

  • The function returns either a single string or an array of strings to be use in the colFilter argument of the labkey.selectRows function.

Details

These filters are applied to the data prior to import into R. The user can specify as many filters as desired. The format for specifying a filter is a vector of characters including the column name, operator and value. [object Object],[object Object],[object Object]

Operator values: EQUAL NOT_EQUAL NOT_EQUAL_OR_MISSING DATE_EQUAL DATE_NOT_EQUAL DATE_GREATER_THAN_OR_EQUAL DATE_LESS_THAN_OR_EQUAL MISSING NOT_MISSING GREATER_THAN GREATER_THAN_OR_EQUAL LESS_THAN LESS_THAN_OR_EQUAL CONTAINS DOES_NOT_CONTAIN STARTS_WITH DOES_NOT_START_WITH IN NOT_IN MV_INDICATOR NO_MV_INDICATOR CONTAINS_ONE_OF CONTAINS_NONE_OF

When using the MISSING, NOT_MISSING, MV_INDICATOR, or NO_MV_INDICATOR operators, an empty string should be supplied as the value. See example below.

References

http://www.omegahat.org/RCurl/, http://dssm.unipa.it/CRAN/web/packages/rjson/rjson.pdf, https://www.labkey.org/project/home/begin.view

See Also

labkey.selectRows

Examples

Run this code
# library(Rlabkey)

## Two filters, ANDed together
filter1<- makeFilter(c("TextFld","CONTAINS","h"), c("BooleanFld","EQUAL","TRUE"))

## Apply a filter in labkey.selectRows function
rows <- labkey.selectRows(
	baseUrl="http://localhost:8080/labkey",
	folderPath="/apisamples",
	schemaName="lists", 
	queryName="AllTypes",
	colFilter=filter1
)
rows

## Using "in" operator:
filter2 <- makeFilter(c("RowId","IN","2;3;6"))
rows <- labkey.selectRows(
	baseUrl="http://localhost:8080/labkey",
	folderPath="/apisamples",
	schemaName="lists", 
	queryName="AllTypes",
	colFilter=filter2
)
rows

## Using "missing" operator:
filter3 <- makeFilter(c("IntFld","MISSING","")) 

rows <- labkey.selectRows(
	baseUrl="http://localhost:8080/labkey",
	folderPath="/apisamples",
	schemaName="lists", 
	queryName="AllTypes",
	colFilter=filter3
)
rows

Run the code above in your browser using DataLab