Operator sub-.fData to subset fData obejcts
This method provides an easy and natural way to subset a functional dataset
stored in a
fData object, without having to deal with the inner
## S3 method for class 'fData' fD[i, j, as_fData = TRUE]
the univariate functional dataset in form of
a valid expression to subset rows ( observations ) of the univariate functional dataset
a valid expression to subset columns ( measurements over the grid ) of the univariate functional dataset.
logical flag to specify whether the output should be returned
The method returns either an
fData object ( if
= TRUE ) or a
matrix ( if
as_fData = FALSE ) containing the
required subset ( both in terms of observations and measurement points ) of
the univariate functional dataset.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
N = 20 P = 1e2 # One dimensional grid grid = seq( 0, 1, length.out = P ) # Generating an exponential covariance function (see related help for more # information ) C = exp_cov_function( grid, alpha = 0.3, beta = 0.4 ) # Generating a synthetic dataset with a gaussian distribution and # required mean and covariance function: fD = fData( grid, generate_gauss_fdata( N, centerline = sin( 2 * pi * grid ), Cov = C ) ) dev.new() par( mfrow = c( 2, 2 ) ) # Original data plot( fD ) # Subsetting observations plot( fD[ c(1,2,3), , as_fData = TRUE ] ) # Subsetting measurements plot( fD[ , 1 : 30 ] ) # Subsetting both observations and measurements plot( fD[ 1 : 10, 50 : P ] ) # Subsetting both observations and measurements but returning a matrix fD[ 1 : 10, 50 : P, as_fData = FALSE ]
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.