File: anyMissing.Rd

package info (click to toggle)
r-cran-checkmate 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,504 kB
  • sloc: ansic: 2,196; sh: 9; makefile: 8
file content (47 lines) | stat: -rw-r--r-- 1,515 bytes parent folder | download | duplicates (2)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/allMissing.R, R/anyMissing.R
\name{allMissing}
\alias{allMissing}
\alias{anyMissing}
\title{Check if an object contains missing values}
\usage{
allMissing(x)

anyMissing(x)
}
\arguments{
\item{x}{[\code{ANY}]\cr
Object to check.}
}
\value{
[\code{logical(1)}] Returns \code{TRUE} if any (\code{anyMissing}) or all (\code{allMissing})
 elements of \code{x} are missing (see details), \code{FALSE} otherwise.
}
\description{
\code{anyMissing} checks for the presence of at least one missing value,
\code{allMissing} checks for the presence of at least one non-missing value.
Supported are atomic types (see \code{\link[base]{is.atomic}}), lists and data frames.
Missingness is defined as \code{NA} or \code{NaN} for atomic types and data frame columns,
\code{NULL} is defined as missing for lists.\cr
\code{allMissing} applied to a \code{data.frame} returns \code{TRUE} if at least one column has
only non-missing values. If you want to perform the less frequent check that there is at least
a single non-missing observation present in the \code{data.frame}, use
\code{all(sapply(df, allMissing))} instead.
}
\examples{
allMissing(1:2)
allMissing(c(1, NA))
allMissing(c(NA, NA))
x = data.frame(a = 1:2, b = NA)
# Note how allMissing combines the results for data frames:
allMissing(x)
all(sapply(x, allMissing))
anyMissing(c(1, 1))
anyMissing(c(1, NA))
anyMissing(list(1, NULL))

x = iris
x[, "Species"] = NA
anyMissing(x)
allMissing(x)
}