https://github.com/dyfanjones/inih
Rcpp Bindings to C libray inih (https://github.com/benhoyt/inih) for ini files
https://github.com/dyfanjones/inih
cpp ini r
Last synced: about 2 months ago
JSON representation
Rcpp Bindings to C libray inih (https://github.com/benhoyt/inih) for ini files
- Host: GitHub
- URL: https://github.com/dyfanjones/inih
- Owner: DyfanJones
- License: other
- Created: 2024-12-31T11:53:28.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-31T13:02:09.000Z (over 1 year ago)
- Last Synced: 2025-02-21T05:15:34.813Z (over 1 year ago)
- Topics: cpp, ini, r
- Language: C
- Homepage: https://dyfanjones.r-universe.dev/inih
- Size: 89.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# inih
[](https://CRAN.R-project.org/package=inih)
[](https://app.codecov.io/gh/DyfanJones/inih)
[](https://dyfanjones.r-universe.dev/inih)
A simple wrapper of the [`inih`](https://github.com/benhoyt/inih) C library for reading and writing INI files in R.
## Installation
You can install the development version of inih like so:
Github:
``` r
remotes::install_github("dyfanjones/inih")
```
r-universe:
```r
install.packages("inih", repos = c("https://dyfanjones.r-universe.dev", "https://cloud.r-project.org"))
```
## Example
This is a basic example which shows you how to solve a common problem:
``` {r, read_ini}
library(inih)
demo_ini <- system.file("demo.ini", package = "inih")
read_ini(demo_ini)
```
``` {r, write_ini}
library(inih)
temp_file <- tempfile(fileext = ".ini")
# Create an example configuration list
config <- list(
person = list(name = "John Doe", age = "30", city = "New York"),
job = list(title = "Engineer", company = "ExampleCorp")
)
# Write the configuration to an INI file
write_ini(config, temp_file)
# Check the content of the created INI file
cat(readLines(temp_file), sep = "\n")
# clean up
unlink(temp_file)
```
## Benchmark:
```{r, benchmark}
demo_ini <- system.file("demo.ini", package = "inih")
(bm <- bench::mark(
inih::read_ini(demo_ini),
ini::read.ini(demo_ini),
relative = TRUE
))
ggplot2::autoplot(bm)
```
## Acknowledgements
This project uses the [`inih`](https://github.com/benhoyt/inih) library by Ben Hoyt, which is licensed under the BSD-3-Clause license. You can find the license text in the `inst/LICENSE-inih.txt` file.