View source: R/f_io_utilities.R
| writeKeyValueFile | R Documentation |
Writes a human-editable text file in a widely used key-value format
(INI/.env-like): one entry per line in the form KEY=VALUE.
Blank lines and comment lines (starting with # or ;)
are allowed. Values are written as a single line; special characters
are escaped so that the file remains one key per line.
writeKeyValueFile(
keyValueList,
filePath,
...,
writeHeader = TRUE,
sortKeys = FALSE,
overwrite = TRUE,
safeKeyCheck = TRUE
)
keyValueList |
A named list of scalar (length-1) atomic values.
Supported value types: character, logical, integer, numeric.
|
filePath |
Path to the output file (e.g. |
... |
Currently unused. |
writeHeader |
Logical; if |
sortKeys |
Logical; if |
overwrite |
Logical; if |
safeKeyCheck |
Logical; if |
Keys are restricted to [A-Za-z0-9_.-] to keep the file portable
and easy to edit.
UTF-8 handling: Values are normalized to UTF-8 on write. The file is written
with UTF-8 encoding when supported by the platform. On Windows, UTF-8 is
enforced via fileEncoding = "UTF-8". On other platforms, UTF-8 is
typically the native encoding; we still normalize strings to UTF-8.
Invisibly returns filePath.
## 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
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.