deftype: deftype

View source: R/deftype.R

deftypeR Documentation

deftype

Description

Defines a function which can be used as basis for Andrews curves f_t(t) = \sum_{j=1}^p x_{ij} f_i(t).

Usage

deftype(index = NULL, FUN = NULL, xlim = c(-pi, pi))

Arguments

index

index/name of the function

FUN

function of the form function(n, t) {...}

xlim

default range for displaying curves (default: c(-pi,pi))

Value

either a list of all functions or a single function

Examples

# define a new andrews curve, just with sine curves
deftype("sine", function(n, t) {
          n <- as.integer(if (n<1) 1 else n)
          m <- matrix(NA, nrow=length(t), ncol=n)
          for (i in 1:n) m[,i] <- sin(i*t)
          m
         })
andrews(iris, "sine")
# query
deftype()
deftype("sine")

andrews documentation built on Oct. 23, 2023, 5:08 p.m.