R/get_top_fltquery.R

Defines functions get_top.FltQuery get_top

Documented in get_top

#' Restrict to Top N Results
#'
#' Alters a \code{fltquery} object to only retrieve the first n rows
#'
#' This function alters a \code{fltquery} object so that it will only return
#' the first n records, as defined by the filtering criteria applied by \code{filter}
#'
#' @param qry A fltquery object generated by \code{flt_query}
#' @param n A numeric, indicating the number of rows requested
#' @return A FltQuery object that will only return n rows when run.
#'
#' @examples
#' \dontrun{
#' conn <- connect("joe.bloggs", "mypassword")
#' qry <- flt_query(conn, "my-ems", data_file = "metadata.db")
#' qry <- generate_preset_fieldtree(qry)
#' }
#'
#' @export
#'
get_top <- function(qry, ...) UseMethod("get_top", qry)

#' @export
get_top.FltQuery <- function(qry, n) {
    qry$queryset$top <- n
    return(qry)
  }
ge-flight-analytics/Rems documentation built on May 17, 2023, 8:02 a.m.