View source: R/revalue.levels.R
revalue.levels | R Documentation |
Revalue the names of a level or character column in a dataframe, according to a named vector given as an input
revalue.levels(df, ...)
revalue.levels_(df, dots)
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 |
A data frame (or quitte object, same as data
).
Antoine Levesque
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.