IE: If Then Else

Description Usage Arguments Value Examples

View source: R/econModelBase.R View source: R/Functions.R

Description

1
2
If Then Else
See ? ifelse.xts
1
If Then Else

Usage

1
2
3
IE(x, y, n, ...)

IE(x, y, n, ...)

Arguments

x

xts object

y

if T, select this value

n

if F, select this value

...

dots passed

Value

xts object

xts object

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
40
41
## Not run: 

# IE(If Then Else) examples

xts(matrix(c(T,F),ncol=1), zoo::as.Date(0:1))
           [,1]
1970-01-01  TRUE
1970-01-02 FALSE

IE(xts(matrix(c(T,F),ncol=1), zoo::as.Date(0:1)), 11, 10)
           V1ie
1970-01-01   11
1970-01-02   10

matrix(c(T,F,F,T),ncol=2), zoo::as.Date(0:1)
            [,1]  [,2]
1970-01-01  TRUE FALSE
1970-01-02 FALSE  TRUE

IE(xts(matrix(c(T,F,F,T),ncol=2), zoo::as.Date(0:1)), 11, 10)
           V1ie V2ie
1970-01-01   11   10
1970-01-02   10   11

IE(xts(matrix(c(T,F,F,T),ncol=2), zoo::as.Date(0:1)), c(11,21), c(10,20))
           V1ie V2ie
1970-01-01   11   10
1970-01-02   20   21

xts(matrix(c(11,10),ncol=1), zoo::as.Date(0:1))
           [,1]
1970-01-01   11
1970-01-02   10

# note: some functions, I must test on the coredata. E.g. is.na
IE(xts(matrix(c(11,10),ncol=1), zoo::as.Date(0:1)) > 10 , 21, 20)
           V1ie
1970-01-01   21
1970-01-02   20

## End(Not run)

AndreMikulec/econModel documentation built on June 30, 2021, 9:48 a.m.