isSorted checks wether data are sorted by one or more specified columns.

isSorted(data, columnNames, ascending = rep(TRUE, length(columnNames)))

# S3 method for data.frame
isSorted(data, columnNames, ascending = rep(TRUE,
  length(columnNames)))

# S3 method for ffdf
isSorted(data, columnNames, ascending = rep(TRUE,
  length(columnNames)))

Arguments

data

Either a data.frame of ffdf object.

columnNames

Vector of one or more column names.

ascending

Logical vector indicating the data should be sorted ascending or descending according the specified columns.

Value

True or false

Details

This function currently only supports checking for sorting on numeric values.

Methods (by class)

  • data.frame: Check if a data.frame is sorted by one or more columns

  • ffdf: Check if a ffdf is sorted by one or more columns

Examples

x <- data.frame(a = runif(1000), b = runif(1000)) x <- round(x, digits=2) isSorted(x, c("a", "b"))
#> [1] FALSE
x <- x[order(x$a, x$b),] isSorted(x, c("a", "b"))
#> [1] TRUE
x <- x[order(x$a,-x$b),] isSorted(x, c("a", "b"), c(TRUE, FALSE))
#> [1] TRUE