findXYRow: Find and correct row of a specific categorical variable...

View source: R/sortPW.R

findXYRowR Documentation

Find and correct row of a specific categorical variable combination.

Description

Used for the ggbootPW function, where it may be desired that the variables are put in a specific order along the x and y-axis. Finds the row in a dataframe corresponding to a specific 'x' and 'y' combination, but where the elements that should be in 'x' may be in 'y', and vice versa. It returns that row, with the elements swopped around if need be. If the elements are swopped, the column labelled 'origStat' is multiplied by -1.

Usage

findXYRow(yVar, xVar, plotTbl)

Arguments

xVar, yVar

numeric/character. Elements to set as 'x' and 'y' variables, respectively.

plotTbl

dataframe. Dataframe with columns x, y and origStat. May have other columns. The combination xVar and yVar must only occur once in plotTbl, regardless of order.

Value

Row of dataframe as a dataframe.

Examples

findXYRow( 1, 2, data.frame(x = c( 3, 1, 1 ),
y = c( 2, 2, 1 ),
origStat = c( 0.5, 0.3, -0.2 ) ) )

MiguelRodo/ggboot documentation built on Nov. 9, 2023, 5:45 p.m.