sort_df: Sort a data.frame by column

Description Usage Arguments Value Author(s) See Also Examples

Description

Sorts the columns of a data.frame

Usage

1
sort_df(x, cn, decreasing = FALSE, na.last = NA)

Arguments

x

data.frame on which to perform the sort

cn

character the name of the column(s) to sort.

decreasing

logical should the sort be increasing or decreasing?

na.last

logical see logical; for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed.

Value

character

Author(s)

Thomas P. Harte (originated by John Laing)

See Also

sort, data.frame

Examples

1
2
3
4
5
	 df<- data.frame(Name=c("one","two","three"), Value=1:3)
	 sort_df(df, cn="Value", decreasing=TRUE)
	 # sort first on column "Value", then on column "Name"
	 # note that both columns are sorted with decreasing=TRUE
	 sort_df(df, cn=c("Value","Name"), decreasing=TRUE)

tharte/tutils documentation built on Feb. 11, 2020, 9:17 a.m.