plates: Get available plates or apply function to them

Description Usage Arguments Details Value See Also Examples

Description

Get all plates contained in an OPMS object or a list, or create a list containing a single OPM object as element, or apply a function to a collection of OPM objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  ## S4 method for signature 'MOPMX'
oapply(object, fun, ..., simplify = TRUE)
  ## S4 method for signature 'OPM'
oapply(object, fun, ..., simplify = TRUE)
  ## S4 method for signature 'OPMS'
oapply(object, fun, ..., simplify = TRUE)

  ## S4 method for signature 'MOPMX'
plates(object) 
  ## S4 method for signature 'WMD'
plates(object) 
  ## S4 method for signature 'WMDS'
plates(object) 
  ## S4 method for signature 'list'
plates(object) 

Arguments

object

List, OPM, OPMS or MOPMX object.

fun

A function. Should accept an OPM object as first argument.

...

Optional other arguments passed to fun.

simplify

Logical scalar. If FALSE, the result is a list. If TRUE, it is attempted to simplify this to a vector, matrix or OPMS object (if the result is a list of OPM or OPMA objects). If this is impossible, a list is returned. The MOPMX method tries creating a MOPMX object again after removing NULL values, if any.

Details

The list method of plates traverses the input recursively and skips all objects of other classes than OPM. See also opms, which is somewhat similar but more flexible.

oapply applies a function to all OPM objects within an OPMS object. Optionally it simplifies the result to an OPMS object if possible, or other structures simpler than a list. The OPM method of oapply simply applies fun once (to object).

Value

For plates, a list of OPM objects (may be empty instead if object is a list). The result of oapply depends on fun and simplify: a list, vector, matrix or OPMS object are possible outcomes.

See Also

base::list base::as.list base::sapply

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# plates(), 'OPM' method
summary(x <- plates(vaas_1)) # => list of OPM objects
stopifnot(is.list(x), length(x) == 1L, sapply(x, inherits, what = "OPM"))

# plates(), 'OPMS' method
summary(x <- plates(vaas_4)) # => list of OPM objects
stopifnot(is.list(x), length(x) == 4L, sapply(x, inherits, what = "OPM"))

# plates(), list method
x <- list(vaas_1, letters, vaas_4, 1:10)
summary(x <- plates(x)) # => list of OPM objects
stopifnot(is.list(x), length(x) == 5, sapply(x, inherits, what = "OPM"))

## oapply()
summary(x <- oapply(vaas_4, identity)) # trivial
stopifnot(identical(x, vaas_4))
summary(x <- oapply(vaas_4, identity, simplify = FALSE)) # => yields list
stopifnot(is.list(x), length(x) == 4, sapply(x, class) == "OPMD")

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