Package 'piamutils'

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

Help Index


Delete "+" in Variable Names. Optionally Save in File with Suffix "_withoutPlus"

Description

The function can take a multiple of input formats. It replaces "|+|", "|++|", "|+++|", ... by "|" in variable names and in this "deletes" the "plus-notation".

Usage

deletePlus(mif, writemif = FALSE)

Arguments

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".

Value

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.

Examples

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"

Find the path to R System Files for a given R library

Description

A wrapper around system.file to make sure that the correct paths are returned when working with devtools::load_all() during development.

Usage

getSystemFile(..., package = "base", mustWork = FALSE)

Arguments

...

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

Description

Modify Variable Names

Usage

modifyVariableNames(x, modify, writeMifSuffix = NULL, ...)

Arguments

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

NULL or a suffix for the file name if the result should be written as a mif-file.

...

Further arguments for the modify function.

Value

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

Description

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

Usage

niceround(x, digits = 3)

Arguments

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.

Description

Substitute Placeholders in Variable Names.

Usage

substitutePlaceholder(x, writeMifSuffix = NULL, substitutions = c(. = "$dot$"))

Arguments

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

NULL or a suffix for the filename if the result should be written as a mif-file.

substitutions

A named character vector of placeholders with replacements as names.

Value

If x is not a file path the result is the object x with replaced variable names.

Examples

substitutePlaceholder(c(
  "3$dot$5", # "3.5"
  "3$dot5", # "3$dot5"
  "3.5", # "3.5"
  "$dot$dot$dot$dot$dot$")) # ".dot.dot."