sortDataFrame function

Sorting a data frame by a key

Sorting a data frame by a key

A simple function to sort a data frame based on a certain keyword. This function was posted by r-fanatic at a dzone forum (the webpage is not available anymore).

sortDataFrame(x, key, ...)

Arguments

  • x: The data frame to be sorted.
  • key: The key by which the data frame will be sorted.
  • ...: Further arguments to be passed to the order function.

Returns

The sorted data frame.

References

The original webpage where r-fanatic posted the code is not available as of 3rd April 2017.

Author(s)

r-fanatic

Examples

# Create a simple data frame and order using the "B" key ppp <- data.frame(A=1:10,B=10:1) ppp sortDataFrame(ppp,"B") ppp
  • Maintainer: Alberto Krone-Martins
  • License: GPL (>= 2)
  • Last published: 2017-04-03

Useful links