as-methods: Convert a object slots/fields to a list, json, yaml file

Description Usage Arguments Value Examples

Description

Doesn't like as.list, only fields and slots are converted, prepare a object to be conveted to YAML/JSON.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
asList(object, ...)

## S4 method for signature 'ANY'
asList(object, ...)

## S4 method for signature 'CWL'
asList(object, ...)

## S4 method for signature 'SimpleList'
asList(object, ...)

asYAML(object, ...)

## S4 method for signature 'ANY'
asYAML(object, ...)

asJSON(object, ...)

## S4 method for signature 'ANY'
asJSON(object, ...)

## S4 method for signature 'DSCList'
asList(object, ...)

Arguments

object

object, could be S4/R5 object, for example, class CWL, SimpleList.

...

other parameters passed to as.yaml or toJSON.

Value

a list object or json or yaml file.

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
## define a S4 object
A <- setClass("A", slots = list(a = "character", b = "numeric"))
## define a reference object which extends 'CWL' class
B <- setRefClass("B", fields = list(x = "character", y = "A"), contains = "CWL")
## new instances
a <- A(a = "hello", b = 123)
b <- B(x = "world", y = a)

## show
b
b$show("JSON")
b$show("YAML")

## You can convert slots/fields into a list
asList(a)
asList(b)
b$toList()

##asYAML
asYAML(a)
asYAML(b)
b$toYAML()

##asJSON
asJSON(a)
asJSON(b)
b$toJSON()

tengfei/cwl.R documentation built on May 31, 2019, 8:33 a.m.