Structures representing an individual GADGET data file.

gadget_file(file_name, components = list(), data = NULL, file_type = c())
print(x, ...)
as.character(x, ...)
read.gadget_file(file_name, file_type = c(), fileEncoding = "UTF-8")

## Arguments

file_name

Filename the output should be written to / read from

components

A list of lists, representing each component. See details.

data

A data.frame representing the tabular data at the end of a file.

file_type

A character vector that alters how the file is parsed. Currently either NULL or "bare_component", which implies we write "something" instead of "[something]".

x

fileEncoding

File's characterset. Defaults to UTF-8

...

Unused

## Details

For our purposes, a gadget file is broken down into components, where the first component is any key/value data at the top of the file. Each section separated by "[something]" is considered a new component. Each component is a list of key /values, where values can be vectors of multiple values. Also components can have comments prepended by adding a "preamble" attribute.

In slight deviation to GADGET spec, we insist that tabular data begins with "; -- data --", to avoid any ambiguity on when it starts.

## Value

gadget_file Returns a gadget_file object, a list of components.

print.gadget_file Prints the gadget file as it would be written to the filesystem.

as.character.gadget_file Returns a character string of the gadget file as it would be written to the filesystem.

read.gadget_file Returns a gadget_file object, a list of components.

## Examples

# Simple key/values
list(length = 5, age = 1:5)))
#> ; Generated by mfdb 7.3.99
#> length	5
#> age	1	2	3	4	5

# Multiple components
list(),
component = structure(list(type = "penalty"), preamble = list("comment")),
component = structure(list(type = "penalty"), preamble = list("", "another comment"))))
#> ; Generated by mfdb 7.3.99
#> ; comment
#> [component]
#> type	penalty
#> ;
#> ; another comment
#> [component]
#> type	penalty

# Data