| tfbrackets | R Documentation |
tf vectorsThese functions access, subset, replace and evaluate tf objects.
For more information on creating tf objects and converting them to/from
list, data.frame or matrix, see tfd() and tfb(). See Details.
## S3 method for class 'tf'
x[i, j, interpolate = TRUE, matrix = TRUE]
## S3 replacement method for class 'tf'
x[i] <- value
x |
an |
i |
index of the observations ( |
j |
The |
interpolate |
should functions be evaluated (i.e., inter-/extrapolated)
for values in |
matrix |
should the result be returned as a |
value |
|
Note that these break certain (terrible) R conventions for vector-like objects:
no argument recycling,
no indexing with NA,
no indexing with names not present in x,
no indexing with integers > length(x)
All of the above will trigger errors.
If j is missing, a subset of the functions in x as given by
i.
If j is given and matrix == TRUE, a numeric matrix of function
evaluations in which each row represents one function and each column
represents one argval as given in argument j, with an attribute
arg=j and row- and column-names derived from x[i] and j.
If
j is given and matrix == FALSE, a list of tbl_dfs with columns
arg = j and value = evaluations at j for each observation in
i.
x <- 1:3 * tfd(data = 0:10, arg = 0:10)
plot(x)
# this operator's 2nd argument is quite overloaded -- you can:
# 1. simply extract elements from the vector if no second arg is given:
x[1]
x[c(TRUE, FALSE, FALSE)]
x[-(2:3)]
# 2. use the second argument and optional additional arguments to
# extract specific function evaluations in a number of formats:
x[1:2, c(4.5, 9)] # returns a matrix of function evaluations
x[1:2, c(4.5, 9), interpolate = FALSE] # NA for arg-values not in the original data
x[-3, seq(1, 9, by = 2), matrix = FALSE] # list of data.frames for each function
# in order to evaluate a set of observed functions on a new grid and
# save them as a functional data vector again, use `tfd` or `tfb` instead:
tfd(x, arg = seq(0, 10, by = 0.01))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.