sign2 {ThomasJeffersonUniv} | R Documentation |
Sign of Difference of Two Objects
Description
..
Usage
sign2(
e1,
e2,
name1 = substitute(e1),
name2 = substitute(e2),
na.detail = TRUE,
...
)
Arguments
e1 , e2 |
two R objects, must be both numeric vectors, or ordered factors with the same levels |
name1 , name2 |
|
na.detail |
logical scalar,
whether to provide the missingness details of |
... |
additional parameters, currently not in use |
Details
Function sign2 extends sign in the following ways
Value
Function sign2 returns character vector when na.detail = TRUE
, or
ordered factor when na.detail = FALSE
.
Examples
lv = letters[c(1,3,2)]
x0 = letters[1:3]
x = ordered(sample(x0, size = 100, replace = TRUE), levels = lv)
y = ordered(sample(x0, size = 50, replace = TRUE), levels = lv)
x < y # base R ok
pmax(x, y) # base R okay
pmin(x, y) # base R okay
x[c(1,3)] = NA
y[c(3,5)] = NA
table(sign(unclass(y) - unclass(x)))
table(sign2(x, y))
table(sign2(x, y, na.detail = FALSE), useNA = 'always')
[Package ThomasJeffersonUniv version 0.1.3 Index]