R/filter_dt.R

Defines functions filter_dt

Documented in filter_dt

#' @title Filter entries in data.frame
#' @description Choose rows where conditions are true.
#' @param .data data.frame
#' @param ... List of variables or name-value pairs of summary/modifications
#'   functions.
#' @return data.table
#' @seealso \code{\link[dplyr]{filter}}
#' @examples
#' iris %>% filter_dt(Sepal.Length > 7)
#' iris %>% filter_dt(Sepal.Length == max(Sepal.Length))
#'
#' # comma is not supported in tidyfst after v0.9.8
#' # which means you can't use:
#' \dontrun{
#'  iris %>% filter_dt(Sepal.Length > 7, Sepal.Width > 3)
#' }
#' # use following code instead
#' iris %>% filter_dt(Sepal.Length > 7 & Sepal.Width > 3)
#'

#' @export
filter_dt = function(.data,...){
  dt = as_dt(.data)
  eval.parent(dt[...])
}

Try the tidyfst package in your browser

Any scripts or data that you put into this service are public.

tidyfst documentation built on June 22, 2024, 9:29 a.m.