Package 'HARr'

Title: HAR (GEMPACK) File Read/Write Utility
Description: HAR files are generated and consumed by GEMPACK applications. This package reads/writes HAR files (and SL4 files) directly using basic R functions.
Authors: Maros Ivanic [aut, cre]
Maintainer: Maros Ivanic <[email protected]>
License: CC0
Version: 1.1.0
Built: 2026-06-01 10:49:22 UTC
Source: https://github.com/mivanic/harr

Help Index


Read a GEMPACK HAR file into R

Description

Reads in a GEMPACK HAR file and returns its representation a list. Currently can only process integer headers, real full headers and character headers

Usage

read_har(
  con,
  useCoefficientsAsNames = FALSE,
  toLowerCase = TRUE,
  headersToRead = NULL
)

Arguments

con

Connection or path to HAR file

useCoefficientsAsNames

If a coefficient name is present in the header, use that instead of the four-letter header

toLowerCase

= TRUE Turn all strings to lower case

headersToRead

= NULL A vector of header names to read in

Value

A list of headers


Read an SL4 solution file

Description

This function reads SL4 solution files into a list

Usage

read_SL4(filename, toLowerCase = TRUE)

Arguments

filename

Path to SL4 file

toLowerCase

Logical: should all text from the SL4 file be turned to lowercase

Value

A list of variables


Write an R list to GEMPACK HAR

Description

This function writes a HAR file based on a list. If a list element contains attribute "description," then it is used to define the long header name

Some warnings: (1) you cannot have NA's in a HAR file, (2) empty strings are not allowed, (3) some programs (e.g., GEMPACK models) read chunks of data no longer than 1e4 bytes (set maxSize = 1e4), (4) all dimensions in arrays must have names (see example)

Usage

write_har(data, filename, maxSize = 10000)

Arguments

data

A list

filename

Path to the file to be created

maxSize

Maximum size of data chunk in real array, default of 10,000

Examples

myList = list(TEST = c('Test'))
attr(myList$TEST,'description') = "This is the long header name"
## Not run: write_har(myList,'harfile.har')