to_yaml: Convert to YAML

Description Usage Arguments Details Value References See Also Examples

Description

Convert some R object to YAML or JSON.

Usage

1
2
3
4
5
6
7
  ## S4 method for signature 'MOPMX'
to_yaml(object, ...) 
  ## S4 method for signature 'YAML_VIA_LIST'
to_yaml(object, ...) 
  ## S4 method for signature 'list'
to_yaml(object, sep = TRUE,
    line.sep = "\n", json = FALSE, listify = nodots, nodots = FALSE, ...) 

Arguments

object

Object of one of the classes belonging to YAML_VIA_LIST, or MOPMX object.

sep

Logical scalar. Prepend YAML document separator ‘---’?

line.sep

Character scalar used as output line separator.

json

Logical scalar. Create JSON instead of YAML? If so, sep, line.sep and ... are ignored.

listify

Logical scalar indicating whether after conversion to a list its non-list elements should be converted to lists if they have names. (Names of named vector are not conserved by default in output YAML).

nodots

Logical scalar indicating whether dots in list names should be converted to underscores. This is necessary in some situations (we met this problem when storing JSON documents in a document-oriented database). Converted names will additionally be marked by prepending an underscore, which assists in getting the original spelling back but is anything else than fail-safe.

...

Optional other arguments passed to as.yaml from the yaml package, or arguments passed between the methods.

Details

YAML is a useful data-serialisation standard that is understood by many programming languages. It is particularly more human readable than XML, and vector-like data structures (such as phenotype microarray measurements) can be much more compactly encoded.

Many PM data sets at once can be batch-converted into YAML format using batch_opm. The output format for the child classes is described in detail there, as well as other aspects relevant in practice.

JSON is a subset of YAML and (in most cases) can also be parsed by a YAML parser. For generating JSON, the toJSON function from the rjson package would be used.

Value

Character scalar (YAML string).

References

http://www.yaml.org/

http://www.json.org/

See Also

yaml::as.yaml yaml::yaml.load_file json::toJSON

Other conversion-functions: as.data.frame, extract, extract_columns, flatten, merge, oapply, opmx, plates, rep, rev, sort, split, unique

Examples

1
2
3
4
5
6
7
## Not run: 

# Let 'x' be a any convertible object
# Store the data in file 'out.yml' in YAML format.
write(to_yaml(x), "out.yml")

## End(Not run)

opm documentation built on May 2, 2019, 6:08 p.m.