Learn R Programming

translateSPSS2R (version 1.0.0)

xpssSortVariables: Sorting variables

Description

R implementation of the SPSS SORT VARIABLES function.

Usage

xpssSortVariables(x, by = NULL, order = "A")

Arguments

x
a (non-empty) data.frame or input data of class "xpssFrame".
by
atomic character with the name of the argument to sort by
order
atomic character which indicate the sort direction.

Value

Returns x sorted by the by argument.

Details

x can be sorted based on the following by arguments.
  • NAME. Sort by variable names. Primary sort is alphabetical. Trailing digits are sorted numerically
  • TYPE. Sort variables by type (numeric or string). Sort string variables by width.
  • LABEL. Sort variables alphabetical by variable labels.
  • COLUMNS. Sort variables by column width.

Valid input for order are "Up" or "Down", respectively "A" or "D".

See Also

sort

Examples

Run this code
data(fromXPSS)

xpssSortVariables(fromXPSS, by = "NAME")

xpssSortVariables(fromXPSS, by = "NAME", order = "D")

xpssSortVariables(fromXPSS, by = "TYPE", order = "A")

xpssSortVariables(fromXPSS, by = "TYPE", order = "D")

xpssSortVariables(fromXPSS, by = "COLUMNS", order = "A")

xpssSortVariables(fromXPSS, by = "COLUMNS", order = "D")

Run the code above in your browser using DataLab