View source: R/f_io_utilities.R
| readKeyValueFile | R Documentation |
Reads a human-editable key-value file in a widely used format
(INI/.env-like): KEY=VALUE. Blank lines are ignored.
Full-line comments starting with # or ; are ignored.
Inline comments are supported for unquoted values when preceded by whitespace,
e.g., KEY=123 # comment.
readKeyValueFile(
filePath,
...,
inferTypes = TRUE,
duplicateKeys = c("error", "last", "first"),
safeKeyCheck = FALSE
)
filePath |
Path to the key-value file. |
... |
Currently unused. |
inferTypes |
Logical; if |
duplicateKeys |
How to handle duplicate keys: |
safeKeyCheck |
Logical; if |
Values can be quoted with double quotes. Escape sequences \n,
\r, \t, \\, and \" are supported.
UTF-8 handling: The file is read as UTF-8 and all character values are
normalized to UTF-8 via enc2utf8().
A named list with parsed values.
## Not run:
keyValueList <- list(
STUDY_NAME = "Trial A",
MAX_PATIENTS = 150L,
THRESHOLD = 0.075,
NOTES = "First phase\nSecond phase"
)
filePath <- tempfile(fileext = ".txt")
writeKeyValueFile(
keyValueList = keyValueList,
filePath = filePath,
writeHeader = TRUE,
sortKeys = TRUE,
overwrite = TRUE
)
readKeyValueFile(filePath)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.