Learn R Programming

intoo (version 0.4.0)

2_constructor_utilities: Constructor Utilities

Description

Functions for constructing named lists and S3 objects.

Usage

LIST (…)
EXTEND (object, class, …)

Arguments

object

An object.

class

String, giving the class name. Can be a character vector, in which case, subclasses precede superclasses. Also, can be NULL or missing.

A list of name=value pairs, or objects.

Details

The LIST function constructs/returns a named list, automatically naming it's elements, if names aren't supplied.

The EXTEND function constructs/returns an S3 object, by prepending the (optional) new class to the existing classes, and then assigning attributes.

Note that it's possible to combine the with/EXTEND functions, to take attribute values from a named list.

Examples

Run this code
# NOT RUN {
object <- x <- y <- z <- 1

LIST (x, y, z=0, k=z)

EXTEND (object, "something", x, y, z=0, k=z)
# }

Run the code above in your browser using DataLab