Title: | Utilities for the piam-verse |
---|---|
Description: | This package contains utilities and helpers needed in various piam libraries. |
Authors: | Falk Benke [aut, cre], Christof Schötz [aut] |
Maintainer: | Falk Benke <[email protected]> |
License: | LGPL-3 |
Version: | 0.0.12 |
Built: | 2024-12-13 05:28:42 UTC |
Source: | https://github.com/pik-piam/piamutils |
The function can take a multiple of input formats. It replaces "|+|", "|++|", "|+++|", ... by "|" in variable names and in this "deletes" the "plus-notation".
deletePlus(mif, writemif = FALSE)
deletePlus(mif, writemif = FALSE)
mif |
A path to a mif-file (might be created by confGDX2MIF), a magpie object containing reporting, a quitte object, or a character vector or factor of variable names. |
writemif |
A single truth value. Only used when mif is a file path. Should the new mif with the adjusted names be saved? If yes the new name will have the suffix "_withoutPlus.mif". |
If mif is a file path and writemif
is FALSE
, a MAgPIE
object. If mif is not a file path the result is the object mif
with
replaced variable names.
deletePlus(c( "ab|cd", # "ab|cd" "de|+|fgh", # "de|fgh" "i|j|++|k|l|++++|mno|p", # "i|j|k|l|mno|p" "++|q+|+r|+p+|u+v|+", # "++|q+|+r|+p+|u+v|+" "w|+|+|x")) # "w|x"
deletePlus(c( "ab|cd", # "ab|cd" "de|+|fgh", # "de|fgh" "i|j|++|k|l|++++|mno|p", # "i|j|k|l|mno|p" "++|q+|+r|+p+|u+v|+", # "++|q+|+r|+p+|u+v|+" "w|+|+|x")) # "w|x"
A wrapper around system.file to make sure that the correct paths are returned when working with devtools::load_all() during development.
getSystemFile(..., package = "base", mustWork = FALSE)
getSystemFile(..., package = "base", mustWork = FALSE)
... |
character vectors, specifying subdirectory and file(s) within some package |
package |
a character string with the name of a single package |
mustWork |
if TRUE, an error is given if there are no matching files |
Modify Variable Names
modifyVariableNames(x, modify, writeMifSuffix = NULL, ...)
modifyVariableNames(x, modify, writeMifSuffix = NULL, ...)
x |
A path to a mif-file (might be created by confGDX2MIF), a magpie object containing reporting, a quitte object, or a character vector or factor of variable names. |
modify |
A function that modifies a character vector. |
writeMifSuffix |
|
... |
Further arguments for the modify function. |
If x
is a file path and writeMifSuffix
is NULL
,
a MAgPIE object. If x
is not a file path the result is the object
x
with replaced variable names.
niceround returns human-readable string for big and small numbers Show everything before the dot and at least 'digits' significant digits For a data.frame, convert all numeric columns
niceround(x, digits = 3)
niceround(x, digits = 3)
x |
either a vector or list of numbers, or a dateframe |
digits |
number of significant digits that are definitely kept |
Substitute Placeholders in Variable Names.
substitutePlaceholder(x, writeMifSuffix = NULL, substitutions = c(. = "$dot$"))
substitutePlaceholder(x, writeMifSuffix = NULL, substitutions = c(. = "$dot$"))
x |
A path to a mif-file (might be created by confGDX2MIF), a quitte object, or a character vector or factor of variable names. |
writeMifSuffix |
|
substitutions |
A named character vector of placeholders with replacements as names. |
If x
is not a file path the result is the object x
with
replaced variable names.
substitutePlaceholder(c( "3$dot$5", # "3.5" "3$dot5", # "3$dot5" "3.5", # "3.5" "$dot$dot$dot$dot$dot$")) # ".dot.dot."
substitutePlaceholder(c( "3$dot$5", # "3.5" "3$dot5", # "3$dot5" "3.5", # "3.5" "$dot$dot$dot$dot$dot$")) # ".dot.dot."