vendredi 17 novembre 2017

rbind () on a conditional basis

Here's the question. I have a bunch of if statements that create different data frames (A-F) based on the user inputs. In some instances, some of the data frames will be empty, so maybe (A-C) are empty, but (D-F) have information.

I'm trying to create a conditional rbind(), where it combines the rows only if the data frame is not empty.

I'm not quite sure how to go about this? I don't know if I should create a bunch of conditions and use another if statement:

cond_a <- nrow(a) != 0
cond_b <- nrow(b) != 0
cond_c <- nrow(c) != 0
cond_d <- nrow(d) != 0
cond_e <- nrow(e) != 0
cond_f <- nrow(f) != 0 

but then I don't know how to utilize these conditions...

thanks!

Aucun commentaire:

Enregistrer un commentaire