isSorted: Check if data are sorted by one or more columns

Description Usage Arguments Details Value Methods (by class) Examples

View source: R/NewDataConversion.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
isSorted(data, columnNames, ascending = rep(TRUE, length(columnNames)))

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

## S3 method for class '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.

Details

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

Value

True or false

Methods (by class)

Examples

1
2
3
4
5
6
7
8
9
x <- data.frame(a = runif(1000), b = runif(1000))
x <- round(x, digits=2)
isSorted(x, c("a", "b"))

x <- x[order(x$a, x$b),]
isSorted(x, c("a", "b"))

x <- x[order(x$a,-x$b),]
isSorted(x, c("a", "b"), c(TRUE, FALSE))

Cyclops documentation built on Aug. 24, 2017, 1:02 a.m.