ipmisc (version 2.0.0)

sort_xy: Sorting y column in data by x.

Description

Sorting y column in data by x.

Usage

sort_xy(data, x, y, sort = "none", .fun = mean, ...)

Arguments

data

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.

x

The grouping variable from the dataframe data.

y

The response (a.k.a. outcome or dependent) variable from the dataframe data.

sort

If "ascending" (default), x-variable factor levels will be sorted based on increasing values of y-variable. If "descending", the opposite. If "none", no sorting will happen.

.fun

n summary function. It should take one vector for fct_reorder, and two vectors for fct_reorder2, and return a single value.

...

Currently ignored.

Examples

Run this code
# NOT RUN {
sort_xy(ggplot2::msleep, vore, brainwt, sort = "ascending")
# }

Run the code above in your browser using DataLab