Learn R Programming

iNZightTools (version 1.13.0)

filterNumeric: Filter data by levels of a numeric variables

Description

Filter a dataframe by some boolean condition of one numeric variable and returns the result along with tidyverse code used to generate it.

Usage

filterNumeric(.data, var, op, num)

Value

filtered dataframe with tidyverse code attached

Arguments

.data

a dataframe or survey design object to filter

var

character of the column in .data to filter by

op

a logical operator of "<=", "<", ">=", ">", "==" or "!=" for the boolean condition

num

a number for which the op applies to

Author

Owen Jin, Tom Elliott

See Also

code

Examples

Run this code
filtered <- filterNumeric(iris, var = "Sepal.Length", op = "<=", num = 5)
cat(code(filtered))
head(filtered)

require(survey)
data(api)
svy <- svydesign(~dnum+snum, weights = ~pw, fpc = ~fpc1+fpc2, data = apiclus2)
(svy_filtered <- filterNumeric(svy, var = "api00", op = "<", num = 700))
cat(code(svy_filtered))

Run the code above in your browser using DataLab