Applies numerical differentiation to the values in selected columns of a function value table.
# S3 method for fv
deriv(expr, which = "*", ...,
method=c("spline", "numeric"),
kinks=NULL,
periodic=FALSE,
Dperiodic=periodic)
Function values to be differentiated.
A function value table (object of class "fv"
,
see fv.object
).
Character vector identifying which columns of the table
should be differentiated. Either a vector containing names
of columns, or one of the wildcard strings "*"
or "."
explained below.
Extra arguments passed to smooth.spline
to control the differentiation algorithm, if method="spline"
.
Differentiation method. A character string, partially matched
to either "spline"
or "numeric"
.
Optional vector of \(x\) values where the derivative is allowed to be discontinuous.
Logical value indicating whether the function expr
is periodic.
Logical value indicating whether the resulting derivative should be a periodic function.
Another function value table (object of class "fv"
)
of the same format.
This command performs numerical differentiation on the function values in
a function value table (object of class "fv"
).
The differentiation is performed either by
smooth.spline
or by
a naive numerical difference algorithm.
The command deriv
is generic. This is the
method for objects of class "fv"
.
Differentiation is applied to every column (or to each of the selected columns) of function values in turn, using the function argument as the \(x\) coordinate and the selected column as the \(y\) coordinate. The original function values are then replaced by the corresponding derivatives.
The optional argument which
specifies which of the
columns of function values in expr
will be differentiated.
The default (indicated by the wildcard which="*"
)
is to differentiate all function values, i.e.\ all columns except the
function argument. Alternatively which="."
designates
the subset of function values that are displayed in the default plot.
Alternatively which
can be a character vector containing the
names of columns of expr
.
If the argument kinks
is given, it should be a numeric vector
giving the discontinuity points of the function: the value or values
of the function argument at which the function is
not differentiable. Differentiation will be performed separately on
intervals between the discontinuity points.
If periodic=TRUE
then the function expr
is taken to be
periodic, with period equal to the range of the function
argument in expr
. The resulting derivative is periodic.
If periodic=FALSE
but Dperiodic=TRUE
, then the
derivative is assumed to be periodic. This would be
appropriate if expr
is the cumulative distribution function
of an angular variable, for example.
# NOT RUN {
G <- Gest(cells)
plot(deriv(G, which=".", spar=0.5))
A <- pairorient(redwood, 0.05, 0.15)
DA <- deriv(A, spar=0.6, Dperiodic=TRUE)
# }
Run the code above in your browser using DataLab