powered by
recol() is a small function which can rename columns and change factors to relevant input
recol()
recol(df, old, new, factors=NULL, remove=TRUE, na=NA)
Returns the dataframe with new columns.
dataframe. (df)
df
old column name. (string)
string
new column name. (string)
Named list of factors. If no names then just in alphabetical order (named list)
named list
remove old column from dataframe (boolian)
boolian
the na.strings (list)
list
if (FALSE) { # NUMERIC VARIABLE df <- recol(df, "X5d_55_Alcohol_127", "Alcohol") # FACTOR VARIABLE df <- recol(df, "X5d_55_Alcohol_127", "Alcohol", factors=c("No","Yes")) }
Run the code above in your browser using DataLab