I have two matrices, one of them has a NA value and I want to use a function that only runs if there are NA
s present in the data, so if I run the function it should only work on df2
and not df1
. How would I do this?
df1 <- matrix(1:4, nrow = 2, ncol = 2)
df2 <- matrix(1,2,3,NA, nrow = 2, ncol = 2)
if(all(!is.na(obj))) yourfun(obj)
or it should be the reverse.