I have a data frame in R as: data.frame(A=0.5,B=18,C=0)
. My goal is to check if the data frame has NA
or not. when I run is.na(data.frame(A=0.5,B=18,C=0))
, the output gives give me TRUE/FALSE for each of the columns.
A B C
[1,] FALSE FALSE FALSE
Given the fact that my result will have either NA
for all columns or numeric values for all columns, is there a way to perform something like is.na()
for the data frame and a get an output as a single TRUE or FALSE, instead of column wise TRUE or FALSE?
>Solution :
You could use anyNA
like this:
anyNA(data.frame(A=0.5,B=18,C=0))
#> [1] FALSE
Created on 2023-02-21 with reprex v2.0.2