Learn R Programming

evitaicossa (version 0.0-1)

Extract: Extract or Replace Parts of aaa objects

Description

Extraction methods for aaa objects. The names of the two-letter functions and arguments follow a pattern: the initial letter (s, d, t) stands for “single”, “double”, or “triple”; the second symbol is c for “coefficients”, or a number (1, 2, 3) denoting first, second, or third. Thus “dc()” gets the coefficients of the double-symbol components, and “t2()” gets the second symbol of the triple-symbol components.

Usage

# S4 method for aaa
s1(a)
# S4 method for aaa
sc(a)
# S4 method for aaa
d1(a)
# S4 method for aaa
d2(a)
# S4 method for aaa
dc(a)
# S4 method for aaa
t1(a)
# S4 method for aaa
t2(a)
# S4 method for aaa
t3(a)
# S4 method for aaa
tc(a)
single(a)
double(a)
triple(a)

Value

Return disord or aaa objects

Arguments

a

Object of class aaa

Author

Robin K. S. Hankin

Details

An aaa object is a list of 9 vectors, three numeric and six character, which are extractd by functions s1() etc.

Functions single(), double() and triple() extract the single, double, and triple components of their argument, and return the corresponding aaa object.

There is no function evitaicossa::coeffs() because the three types of elements are qualitatively different; use sc(), dc(), and tc() to get the coefficients in disord format.

Functions getthings(), extracter() and overwriter() are lower-level methods, not really intended for the end-user. Function getthings() takes an aaa object and returns a named list with elements being disord objects corresponding to components s1,sc,d1 etc. Function extracter() takes an aaa object and arguments s1, d1,d2,t1 etc. and returns the aaa object corresponding to the specified index elements. Function overwriter takes

Functions single(), double(), and triple() return the index-1, index-2, and index-3 components of their arguments respectively. Functions single<-() et seq. are the corresponding setting methods which overwrite the index-1 (resp. 2,3) components with the right hand side. The right hand side must be purely the correct compponent otherwise an error is returned; thus in double(a) <- x, for example, the single-symbol and triple-symbol components of x must be zero.

Square bracket extraction and replacement methods are more user-friendly. These operate in two distinct modes. If given named arguments (s1, d1,d2, et seq.) then these are interpreted as symbols and coefficients of the different orders. If given an unnamed argument, this is interpreted as a character vector of length one, two, or three specifying a particular term in the object. See examples.

Examples

Run this code

x <- linear1(1:3) + (linear1(1:2) + linear2(1:3))^2
x
x[d1=c("a","a"),d2=c("a","b")]
x[s1="a", t1="b", t2="c", t3="c"]


x[s1="a", t1="b", t2="c", t3="c"] <- 88
x
x[c("c","c","b")] <- -777
x


a <- raaaa()
sc(a)
t2(a)
single(a)

single(a) + double(a) + triple(a) == a  # should be TRUE

aaa(d1=d1(a),d2=d2(a), dc=dc(a)) == double(a)

x <- raaaa()
single(x) <- 0
double(x) <- double(raaa())

Run the code above in your browser using DataLab