R/rows_.R

Defines functions rows_

#' @importFrom bazar is.wholenumber
#' 
rows_ <- 
function(.condition, 
         .data)
{
  n <- nrow(.data)
  if (missing(.condition) || is.null(.condition)) {
    w <- seq_len(n)
  } else if (is.logical(.condition) && length(.condition)==n) {
    w <- which(.condition)
  } else if (is.logical(.condition) && length(.condition)==1L) {
    w <- which(rep(.condition, n))
  } else if (bazar::is.wholenumber(.condition)) {
    w <- .condition
  } else {
    stop("incorrect '.condition' argument")
  }
  w
}

Try the lplyr package in your browser

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

lplyr documentation built on Nov. 17, 2017, 7:34 a.m.