gadget_file: Gadget file objects

Description Usage Arguments Details Examples

Description

Structures representing an individual GADGET data file.

Usage

1
2
3
4
5
6
gadget_file(file_name, components = list(), data = NULL)
## S3 method for class 'gadget_file'
print(x, ...)
## S3 method for class 'gadget_file'
as.character(x, ...)
read.gadget_file(file_name, 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.

x

gadget_file object

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Simple key/values
gadget_file("age", components = list(
    list(length = 5, age = 1:5)))
## Not run: 
; Generated by mfdb 1.0
length	5
age	1	2	3	4	5

## End(Not run)

# Multiple components
gadget_file("likelihood", components = list(
    list(),
    component = structure(list(type = "penalty"), preamble = list("comment")),
    component = structure(list(type = "penalty"), preamble = list("", "another comment"))))
## Not run: 
; Generated by mfdb 1.0
; comment
[component]
type	penalty
; 
; another comment
[component]
type	penalty

## End(Not run)

# Data
gadget_file("agelen", components = list(
    list(stocknames = "big boat")), data = data.frame(
    area = c(102, 103),
    number = c(2345, 5023)))
## Not run: 
; Generated by mfdb 1.0
stocknames	big	boat
; -- data --
; area number
102	2345
103	5023

## End(Not run)

sCervino/mfdb documentation built on May 18, 2019, 1:31 p.m.