scale_by_predicate: Expand variables in a data frame via logical conceptual...

Description Usage Arguments Value Examples

Description

Expand variables in a data frame via logical conceptual scaling

Usage

1
scale_by_predicate(data, predicates)

Arguments

data

Data frame.

predicates

A logical expression involving variables in data, or a list of such expressions. If a list, then the names of any named elements will be used as column names in the resulting context.

Value

A binary numeric matrix (formal context) of nrow(data) rows and 1 column, whose entries are the truth values of predicate applied to the rows of data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# logical expressions involving single variables
scale_by_predicate(mtcars, cyl == 8)
scale_by_predicate(mtcars, mpg > 20)

# logical expressions involving multiple variables
scale_by_predicate(mtcars, cyl > 4 & wt < 3)

# multiple logical expressions
scale_by_predicate(mtcars, list(cyl > 4, wt < 3, mpg > 20))

# singleton list
scale_by_predicate(mtcars, list(cyl == 6))

# list with some predicates named
scale_by_predicate(mtcars, list(`4-cyl` = cyl == 4,
                                wt > 2,
                                goodMPG = mpg > 20))

corybrunson/context documentation built on May 13, 2019, 10:52 p.m.