filter_num {iNZightTools} | R Documentation |
Filter data by levels of numeric variables
Description
This function filters a dataframe or survey design object by applying a specified boolean condition to one of its numeric variables. The resulting filtered dataframe is returned, along with the tidyverse code used to generate it.
Usage
filter_num(data, var, op = c("<=", "<", ">=", ">", "==", "!="), num)
Arguments
data |
A dataframe or survey design object to be filtered. |
var |
The name of the column in |
op |
A logical operator to apply for the filtering condition. Valid options are: "<=", "<", ">=", ">", "==", or "!=". |
num |
The numeric value for which the specified |
Value
A filtered dataframe with the tidyverse code attached.
Author(s)
Owen Jin, Tom Elliott, Zhaoming Su
See Also
Examples
filtered <- filter_num(iris, var = "Sepal.Length", op = "<=", num = 5)
cat(code(filtered))
head(filtered)
library(survey)
data(api)
svy <- svydesign(~ dnum + snum,
weights = ~pw, fpc = ~ fpc1 + fpc2,
data = apiclus2
)
svy_filtered <- filter_num(svy, var = "api00", op = "<", num = 700)
cat(code(svy_filtered))
[Package iNZightTools version 2.0.1 Index]