Learn R Programming

salad (version 1.2)

Summary: Summary methods for objects of class dual

Description

Methods extending to dual objects the corresponding methods for numeric objects.

Usage

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

# S4 method for numericOrArray sum(x, ..., na.rm = FALSE)

# S3 method for dual prod(x, ..., na.rm = FALSE)

# S4 method for numericOrArray prod(x, ..., na.rm = FALSE)

# S3 method for dual max(x, ..., na.rm = TRUE)

# S4 method for numericOrArray max(x, ..., na.rm = TRUE)

# S3 method for dual min(x, ..., na.rm = TRUE)

# S4 method for numericOrArray min(x, ..., na.rm = TRUE)

# S3 method for dual range(x, ..., na.rm = TRUE)

# S4 method for numericOrArray range(x, ..., na.rm = TRUE)

# S4 method for dual which.min(x)

# S4 method for dual which.max(x)

Value

`which.min` and `which.max` return an integer, the other methods return a dual object.

Arguments

x

a dual object

...

extra arguments

na.rm

if 'TRUE', NA values are removed

Details

For `max` and `min`, the derivative is equal to the derivative of maximum element as identified by `which.max` and `which.min`. This is unfortunately problematic in presence of ties. If this is an issue, you may redefine this function (at the expense of speed).

Examples

Run this code
x <- dual( c(1,2,4) )
sum(x)
d(sum(x), "x1")

Run the code above in your browser using DataLab