recol: Reorder column (recol)

View source: R/recol.R

recolR Documentation

Reorder column (recol)

Description

recol() is a small function which can rename columns and change factors to relevant input

Usage

recol(df, old, new, factors=NULL, remove=TRUE, na=NA)

Arguments

df

dataframe. (df)

old

old column name. (string)

new

new column name. (string)

factors

Named list of factors. If no names then just in alphabetical order (⁠named list⁠)

remove

remove old column from dataframe (boolian)

na

the na.strings (list)

Value

Returns the dataframe with new columns.

Examples

## Not run: 
   # NUMERIC VARIABLE
   df <- recol(df, "X5d_55_Alcohol_127", "Alcohol")
   # FACTOR VARIABLE
   df <- recol(df, "X5d_55_Alcohol_127", "Alcohol", factors=c("No","Yes"))

## End(Not run)


clintools documentation built on May 29, 2024, 7:14 a.m.