Package to Parse an INI File, Including Variable Interpolation

Enhances the 'ini' package by adding the ability to interpolate variables. The INI configuration file is read into an R6 ConfigParser object (loosely inspired by Pythons ConfigParser module) and the keys can be read, where '%(....)s' instances are interpolated by other included options or outside variables.

Build Status AppVeyor Build Status CRAN_Status_Badge Coverage Status

Getting Started

We can generate a new ConfigParser object and pre-seed a few variable values. Then we set several options in a new section 'Section 1'.

config <- ConfigParser$new(init=c("bar"="Life", "baz"="too short"))
config$set(option=c("a_bool", "a_float", "foo"), value=c("true", "3.1415", "%(bar)s is %(baz)s"),
           section="Section 1", error_on_new_section=FALSE)

Of these we can then read out specific values in the form of a string or also directly ask for a float or a boolean.

config$get("foo", NA, "Section 1")
config$getboolean("a_bool", NA, "Section 1")
config$getfloat("a_float", NA, "Section 1")

It is also easy to pre-seed a config file with e.g. all environment variables, this time setting the optionxform to identity to prevent the default lower-casing of all options and then read an INI file from disk.

config <- ConfigParser$new(Sys.getenv(), optionxform=identity)
config$read(system.file("test.INI", package="ConfigParser"))

The manual shows a few other functions, but these basics here should get everyone started.


ConfigParser Version 1.0.0

  • Initial release of the package

  • Adds ability to interpolate variabels to the 'ini' package

  • Inspired by the ConfigParser module in Python

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.0.0 by Holger Hoefling, 2 years ago

Report a bug at

Browse source code at

Authors: Holger Hoefling [aut, cre]

Documentation:   PDF Manual  

GPL-3 license

Depends on ini, R6

Suggests testthat

See at CRAN