revalue.levels: Revalue data frame factor levels.

View source: R/revalue.levels.R

revalue.levelsR Documentation

Revalue data frame factor levels.

Description

Revalue the names of a level or character column in a dataframe, according to a named vector given as an input

Usage

revalue.levels(df, ...)

revalue.levels_(df, dots)

Arguments

df

A data frame (or quitte object).

...

Name-value pairs assigning a named vector with new names to a column from the dataframe.

dots

A named list of columns containing the named vector with the old and new names for each column

Value

A data frame (or quitte object, same as data).

Author(s)

Antoine Levesque

Examples


data <- inline.data.frame(c(
  "model;    scenario;   region;   variable;           unit;         period;   value",
  "REMIND;   Baseline;   USA;      GDP per Capita|MER; US$2005/yr;   2010;     40000",
  "REMIND;   Baseline;   USA;      Population;         million;      2010;     300",
  "REMIND;   Baseline;   CHN;      GDP per Capita|MER; US$2005/yr;   2010;     7000"))

reg_vec = c(USA = "United States")
var_vec = c("GDP per Capita|MER" = "gdp",
           Population = "pop")

revalue.levels(data,region = reg_vec)
revalue.levels_(data,list(region = reg_vec, variable = var_vec))


pik-piam/quitte documentation built on April 26, 2024, 12:58 a.m.