argvals: Extract and set slots from functional data objects

Description Usage Arguments Details Value Warning See Also Examples

Description

These functions can be used to extract and set the slots of funData, irregFunData and multiFunData objects.

Usage

 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
argvals(object)

getArgvals(object)

## S4 method for signature 'funData'
getArgvals(object)

## S4 method for signature 'multiFunData'
getArgvals(object)

## S4 method for signature 'irregFunData'
getArgvals(object)

X(object)

getX(object)

## S4 method for signature 'funData'
getX(object)

## S4 method for signature 'multiFunData'
getX(object)

## S4 method for signature 'irregFunData'
getX(object)

argvals(object) <- value

setArgvals(object, value)

## S4 method for signature 'funData'
setArgvals(object, value)

## S4 method for signature 'multiFunData'
setArgvals(object, value)

## S4 method for signature 'irregFunData'
setArgvals(object, value)

X(object) <- value

setX(object, value)

## S4 method for signature 'funData'
setX(object, value)

## S4 method for signature 'multiFunData'
setX(object, value)

## S4 method for signature 'irregFunData'
setX(object, value)

Arguments

object

An object of class funData, irregFunData or multiFunData.

value

New argvals or X. See Details.

Details

Objects of class funData or irregFunData have two slots, argvals (for the x-values) and X (for the y-values for each observation). Using the argvals (alias: getArgvals) and X (alias: getX) methods for the classes funData and irregFunData is equivalent to accessing the slots directly via object@argvals and object@X. Analogously, the argvals<- and X<- functions are equivalent to setting object@argvals to value or object@X to value, respectively. The new values must hence have the same structure as the original ones. As an exception, for an object of class funData the number of new X values may differ from the current (e.g. when adding new observations). In this case, the function throws a warning.

Objects of class multiFunData are lists of several funData objects. The functions argvals and X for multiFunData objects therefore return a list of the same length as object, where each list element corresponds to the argvals or X slot of the univariate element. The argvals<- and X<- functions for multiFunData objects must receive lists of the same length as object, where each list element corresponds to the new argvals or new X slot for the univariate elements.

Value

See Details.

Warning

The functions getArgvals / getX and setArgvals / setX from former package versions are deprecated. use argvals and X instead.

See Also

funData, irregFunData, multiFunData

Examples

 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
35
36
37
38
39
### Univariate
object <- funData(argvals = 1:5, X = rbind(1:5, 6:10))
object

# get-methods
argvals(object)
X(object)

# set-methods
argvals(object) <- 0:4
object 
## Not run: argvals(object) <- 1:4 # wrong length
X(object) <- rbind(0:4, 5:9)
## Not run: X(object) <- rbind(0:4, 5:9, 10:14) # warning: now 3 observations (was 2 before)
## Not run: X(object) <- rbind(1:4, 5:8) # wrong length

### Univariate (irregular)
irregObject <- irregFunData(argvals = list(1:5, 2:4), X = list(2:6, 3:5))
irregObject

# get-methods
argvals(irregObject)
X(irregObject)

# set-methods
argvals(irregObject) <- list(0:4, 1:3)
X(irregObject) <- list(12:16, 13:15)

### Multivariate
multiObject <- multiFunData(object, funData(argvals = 1:3, X = rbind(3:5, 6:8)))
multiObject

# get-methods
argvals(multiObject)
X(multiObject)

# set-methods (for special cases see univariate version)
argvals(multiObject) <- list(5:1, 3:1)
X(multiObject) <- list(rbind(5:1, 10:6), rbind(5:3, 8:6))

Example output

Attaching package: 'funData'

The following object is masked from 'package:stats':

    integrate

Functional data with 2 observations of 1-dimensional support
argvals:
	1 2 3 4 5		(5 sampling points)
X:
	array of size 2 x 5 
[[1]]
[1] 1 2 3 4 5

     [,1] [,2] [,3] [,4] [,5]
[1,]    1    2    3    4    5
[2,]    6    7    8    9   10
Functional data with 2 observations of 1-dimensional support
argvals:
	0 1 2 3 4		(5 sampling points)
X:
	array of size 2 x 5 
Irregular functional data with 2 observations of 1-dimensional support
argvals:
	Values in 1 ... 5.
X:
	Values in 2 ... 6.
Total:
	8 observations on 5 different argvals (3 - 5 per observation).
[[1]]
[1] 1 2 3 4 5

[[2]]
[1] 2 3 4

[[1]]
[1] 2 3 4 5 6

[[2]]
[1] 3 4 5

An object of class "multiFunData"
[[1]]
Functional data with 2 observations of 1-dimensional support
argvals:
	0 1 2 3 4		(5 sampling points)
X:
	array of size 2 x 5 

[[2]]
Functional data with 2 observations of 1-dimensional support
argvals:
	1 2 3		(3 sampling points)
X:
	array of size 2 x 3 

[[1]]
[[1]][[1]]
[1] 0 1 2 3 4


[[2]]
[[2]][[1]]
[1] 1 2 3


[[1]]
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    1    2    3    4
[2,]    5    6    7    8    9

[[2]]
     [,1] [,2] [,3]
[1,]    3    4    5
[2,]    6    7    8

funData documentation built on Oct. 17, 2021, 5:06 p.m.