visualizeR/man/reorder_by.Rd
2025-02-09 17:19:54 +01:00

42 lines
1.1 KiB
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reorder_by.R
\name{reorder_by}
\alias{reorder_by}
\title{Reorder a Data Frame}
\usage{
reorder_by(df, x, y, group = "", order = "y", dir_order = 1)
}
\arguments{
\item{df}{A data frame to be reordered.}
\item{x}{A character scalar specifying the column to be reordered.}
\item{y}{A character scalar specifying the column to order by if ordering by values.}
\item{group}{A character scalar specifying the grouping column (optional).}
\item{order}{A character scalar specifying the order type (one of "none", "y", "grouped"). See details.}
\item{dir_order}{A logical scalar specifying whether to flip the order.}
}
\value{
The reordered data frame.
}
\description{
Reorder a Data Frame
}
\details{
Ordering takes the following possible values:
* "none": No reordering.
* "y": Order by values of y.
* "grouped_y": Order by values of y and group.
* "x": Order alphabetically by x.
* "grouped_x": Order alphabetically by x and group.
}
\examples{
# Example usage
df <- data.frame(col1 = c("b", "a", "c"), col2 = c(10, 25, 3))
reorder_by(df, "col1", "col2")
}