Learn R Programming

fdars (version 0.3.3)

as.fdata.irregFdata: Convert Irregular Functional Data to Regular Grid

Description

Creates a regular fdata object from an irregFdata object by interpolating or placing NA at unobserved points.

Usage

# S3 method for irregFdata
as.fdata(x, argvals = NULL, method = c("na", "linear", "nearest"), ...)

as.fdata(x, ...)

# S3 method for fdata as.fdata(x, ...)

Value

An fdata object with NA for unobserved points (unless interpolated).

Arguments

x

An object of class irregFdata.

argvals

Target regular grid. If NULL, uses the union of all observation points.

method

Interpolation method:

na

(Default) Only fill exact matches; other points are NA

linear

Linear interpolation between observed points

nearest

Nearest neighbor interpolation

...

Additional arguments (ignored).

See Also

sparsify, irregFdata

Examples

Run this code
# Create sparse data
t <- seq(0, 1, length.out = 100)
fd <- simFunData(n = 10, argvals = t, M = 5, seed = 42)
ifd <- sparsify(fd, minObs = 10, maxObs = 30, seed = 123)

# Convert back to regular grid with NA
fd_na <- as.fdata(ifd)

# Convert with linear interpolation
fd_interp <- as.fdata(ifd, method = "linear")

Run the code above in your browser using DataLab