samedi 22 octobre 2016

R: if condition on empty data frame returns error in if (d2 == 0L) { : missing value where TRUE/FALSE needed

I am trying to extract values from a nested list of data frames. One data frame has a column which is data frame and sometimes it is empty. Therefore I used the if condition, as suggested in this post:
Why does an empty dataframe fail an is.null() test? if (is.data.frame(df) && nrow(df)==0)

However, I get error as:

Error in if (d2 == 0L) { : missing value where TRUE/FALSE needed

Can someone teach me how to make an if condition to return TRUE/FALSE on whether a data frame is empty or not?

Thanks.

Aucun commentaire:

Enregistrer un commentaire