Sort data frame by variable(s) {epicalc}R Documentation

Sort data frame by variable(s)

Description

Sort the whole dataset by one or more variables

Usage

sortBy(..., dataFrame = .data)

Arguments

... index variable(s) used for sorting
dataFrame Destination data frame where all variables of the same length are sorted

Details

The whole dataset, and the variables outside, can be sorted by an index variable(s) inside the (...).

Author(s)

Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

See Also

'sort', 'order'

Examples


sbp <- c(120, 100, 110, 120, 140, 120,  NA,  NA) 
dbp <- c( 80,  80,  70,  80,  70,  NA,  70,  60)
.data <- data.frame(sbp, dbp)
use(.data)
age <- c(37, 32, 24, 33, 31, 30, 26, 25)
age2 <- age^2
sortBy(age)
pack()
des()
.data
sortBy(age, decreasing=TRUE)
.data

## Note that the argument of 'sortBy' must not be concatenated vectors
data(Familydata)
use(Familydata)
.data
sortBy(money, sex) # correct
.data
use(Familydata) # Read in the dataset afresh
sortBy(c(money, sex)) # errors.
.data

[Package epicalc version 2.7.0.1 Index]