-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathallNA.Rd
40 lines (39 loc) · 1.27 KB
/
allNA.Rd
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Data_handling.R
\name{allNA}
\alias{allNA}
\title{Find Rows or Columns with Only NAs Over Array Margins}
\usage{
allNA(x, margin)
}
\arguments{
\item{x}{An array, including a matrix.}
\item{margin}{A vector giving the subscripts which the function will be
applied over. E.g., for a matrix \code{1} indicates rows, \code{2}
indicates columns, \code{c(1, 2)} indicates rows and columns. Where
\code{x} has named dimnames, it can be a character vector selecting
dimension names.}
}
\description{
\code{allNA} returns a logical vector or array or list indicating whether
there are only \code{NA} values in selected margins and therefore e.g.
statistics like \code{max} or \code{min} do not produce useful results.
}
\examples{
\dontrun{
xx <- matrix(1:20, nrow = 4)
xx[2, ] <- NA
allNA(xx, 2) # All columns have at least one non-missing value
allNA(xx, 1) # Second row has all values missing
apply(xx, 1, max, na.rm = TRUE)
## returns c(17, -Inf, 19, 20) and a warning message
## Skip the allNA row in apply()
apply(xx[!allNA(xx, 1), ], 1, max, na.rm = TRUE)
}
}
\seealso{
\code{\link{NA}} for general information about NAs and
\code{\link{apply}} for \code{apply} description.
}
\concept{NA handlers}
\keyword{internal}