Learn R Programming

polynomial (version 0.1.0)

coef<-: Replace Coefficients

Description

coef<- is a generic function which replaces the coefficients of a polynomial. coefficients<- is an alias for it.

Usage

coef(object, ...) <- value
coefficients(object, ...) <- value

# S3 method for default coef(object, …) <- value

Arguments

object

any object.

further arguments passed to or from other methods. The default method passes these arguments to as.numbers.

value

a numeric or complex vector, or an object which can be coerced by as.numbers to a numeric or complex vector.

Value

For coef<-, the updated object. (Note that the value of coef(object, ...) <- value is that of the assignment, value, not the return value from the left-hand side.)

Details

All attributes of object are retained except for the class attribute which is set to "polynomial".

Examples

Run this code
# NOT RUN {
x <- as.polynomial(Hermite(5))
names(x) <- c("a", "b", "c", "d", "e", "f")
print(x)

coef(x) <- 1:6
print(x)  # names are preserved

coef(x)[2] <- 0
print(x)
# }

Run the code above in your browser using DataLab