Learn R Programming

baizer (version 0.8.0)

filterC: apply tbflt on dplyr filter

Description

apply tbflt on dplyr filter

Usage

filterC(.data, tbflt = NULL, .by = NULL, usecol = TRUE)

Value

tibble

Arguments

.data

tibble

tbflt

tbflt object

.by

group by, same as .by argument in dplyr::filter

usecol

if TRUE (default), use the default behavior of dplyr::filter(), which allows the usage of same variable in colnames, and filter by the data column. If FALSE, will check whether the variables on the right side of ==,>,<,>=,<= have same names as columns and raise error, for the sake of more predictable results. You can always ignore this argument if you know how to use .env or !!

Examples

Run this code
c1 <- tbflt(cut == "Fair")

c2 <- tbflt(x > 8)

mini_diamond %>%
  filterC(c1) %>%
  head(5)

mini_diamond %>% filterC(c1 & c2)



x <- 8
cond <- tbflt(y > x)

# variable `x` not used because of column `x` in `mini_diamond`
filterC(mini_diamond, cond)

# will raise error because `x`  is on the right side of `>`
# filterC(mini_diamond, cond, usecol=FALSE)

# if you know how to use `.env` or `!!`, forget argument `usecol`!
cond <- tbflt(y > !!x)
filterC(mini_diamond, cond)

cond <- tbflt(y > .env$x)
filterC(mini_diamond, cond)

Run the code above in your browser using DataLab