Type: Package
Title: 'HAR' ('GEMPACK') File Read/Write Utility
Version: 1.1.0
Author: Maros Ivanic [aut, cre]
Description: HAR files are generated and consumed by 'GEMPACK' applications. This package reads/writes 'HAR' files (and 'SL4' files) directly using basic R functions.
License: CC0
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: stringi
NeedsCompilation: no
Packaged: 2025-08-21 18:53:30 UTC; ivani
Maintainer: Maros Ivanic <ivanic@gmail.com>
Repository: CRAN
Date/Publication: 2025-08-27 12:00:29 UTC

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

Examples

fl <- system.file("extdata/test.sl4", package="HARr")
read_SL4(fl)

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

Examples

fl <- system.file("extdata/example1.har", package="HARr")
read_har(fl)

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

Value

No return value, called for side effects

Examples

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