Create lists of variables from Causata for queries.

Description

This collection of functions is used to create lists of variables from Causata. The lists can be inputs to queries using the Causata SQL interface.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'Connect'
Vinclude(this, name.patterns=NULL, label.patterns=NULL, 
  and=TRUE, ...)

## S3 method for class 'Connect'
Vexclude(this, variable.names=NULL, name.patterns=NULL, 
  label.patterns=NULL, and=TRUE, ...)

## S3 method for class 'Connect'
Vtime(this, variable.names, domains, ...)

BacktickCollapse(variable.names)

Arguments

this

An object from the class Connect. This object stores the list of available variable names and time domains.

name.patterns

A character vector of variable system name patterns that will be used with grep to find matches.

label.patterns

A character vector of variable label names patterns that will be used with grep to find matches.

and

If multiple filtering arguments are supplied, then this controls whether variables have to match all of the criteria (and=TRUE) or any of the criteria (and=FALSE).

variable.names

Character vector containing Causata variable system names.

domains

Character vector containing Causata variable time domains.

...

Extra unused arguments.

Details

These functions create lists of variables that are filtered according to the given criteria.

Vinclude returns a character array of all variables matching the provided criteria. If the criteria are left at their default values (NULL) then a list of all available variables is returned.

Vexclude works in the same manner as Vinclude, except that variables matching the criteria are excluded. If variable.names is NULL then the matching process begins with all avaible variables. If variable.names contains variable names then the matching process will select from the provided names.

Vtime appends time domains to the variables.

To see a list of the available variables and time domains, open a Connect object and view the embedded data frames of variable metadata. See the example below for details.

Value

Vinclude, Vexclude, and Vtime return a vector of character strings naming variables found in Causata.

BacktickCollapse returns a single character string with the variables names concatenated together and surrounded by backticks. This string can be used directly in a SQL query to Causata.

Author(s)

Justin Hemann <support@causata.com>

See Also

Connect, grep.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Some of these examples require a Causata connection, so they are not run
## Not run: 
conn <- Connect(group="example")

# View available variables
View(conn$variables)

# View available time ranges
View(conn$timeRanges)

# View available time points
View(conn$timePoints)

# Get a list of variables matching the given labels: all online and demographics
variables <- Vinclude(conn, label.patterns=c("online", "demographics"))

# Get a list of all variables except those with "test" in the name
variables <- Vexclude(conn, name.patterns="test")

# build a query string and extract data
query.str <- paste(
  "select", BacktickCollapse(variables),
  "from customers")
df <- GetData(conn, query.str)
Close(conn)

## End(Not run)

# simple example with BacktickCollapse
BacktickCollapse(c("variable-one", "variable-two"))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.