Learn R Programming

freegroup (version 1.2-1-1)

sum: Repeated summation by concatenation

Description

Concatenates its arguments to give a single free object

Usage

# S3 method for free
sum(..., na.rm = FALSE)

Arguments

...

Objects of class free, to be summed

na.rm

Boolean, indicating whether to ignore NA entries (currently ignored)

Author

Robin K. S. Hankin

Details

Function sum() concatenates its arguments and gives a single element of the free group. It works nicely with rev(), see the examples. Note that sum(x,y) is not the same as x+y.

Examples

Run this code

(x <- rfree(10,3))
sum(x)
abelianize(sum(x))

(y <- rfree(10,6))

sum(x,y)
sum(x,y) == sum(sum(x),sum(y))
x+y  # not the same!

sum(x,-x)
sum(x,rev(-x))

z <- alpha(26)
stopifnot(sum(x^z) == sum(x)^z)

Run the code above in your browser using DataLab