simple_relevel: Relevel in correspondence to another factor

View source: R/simple_relevel.R

simple_relevelR Documentation

Relevel in correspondence to another factor

Description

Function to relevel a variable in accordance to a another variable of class "factor".

Usage

simple_relevel(x, ...)

## S3 method for class 'data.frame'
simple_relevel(data, ..., by)

## Default S3 method:
simple_relevel(x, by, map, value = c("unsorted", "sorted", "levels"))

Arguments

x

a vector that will be relevelled

...

Unquoted variable names that will be relevelled

data

A data.frame

by

a vector that the relevelling process will base on

map

a list that links by to x in the form of list(by.1 = c(x1.1, x1.2...), by.2 = c(x2.1, x2.2...)) or a data.frame with two columns "from" and "to" serving the same purpose.

value

a string: whether to return

- "levels": new levels only

- "unsorted" (default): an unsorted, relevelled factor

- "sorted": a sorted, relevelled factor

Value

An object of the same class as the input

A factor or a numeric vector of order


oucru-biostats/C306 documentation built on July 16, 2024, 2:33 p.m.