Description Usage Arguments Value Examples
Remove NA
s codeNaNs and codeInfs from data
1 2 3 4 5 6 7 8 9 10 11 12 | keep_finite(x, ...)
## Default S3 method:
keep_finite(x, ...)
## S3 method for class 'matrix'
keep_finite(x, margin = 1, keep = c("any",
"complete"), ...)
## S3 method for class 'data.frame'
keep_finite(x, margin = 1, keep = c("any",
"complete"), ...)
|
x |
a vector or matrix |
... |
further arguments passed to methods |
margin |
if |
keep |
if |
If x
is a matrix and margin
is 1 or 2, a matrix is returned.
Else a vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | m1 <- matrix(c(10, 20, 30, 43,
10, NA, 32, 50,
NA, NA, NA, NA,
13, 22, 70, 81,
NA, 29, NA, 41), 5, byrow=TRUE,
dimnames=list(letters[1:5], LETTERS[1:4]))
keep_finite(m1)
matplot(keep_finite(apply(m1, 2, sort, na.last=TRUE)), type="l")
m1[complete.cases(m1),]
keep_finite(m1, 1, "c") #same
keep_finite(m1, 2, "complete") #no complete columns
m1.df <- as.data.frame(t(m1))
keep_finite(m1.df, 2, "complete")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.