Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

single TRUE/FALSE for entire data frame in R

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading