I noticed that sometimes I get errors in my R scripts when I forget checking whether the dataframe I'm working on is actually empty (has zero rows).
For example, when I used apply like this
apply(X=DF,MARGIN=1,FUN=function(row) !any(vec[ row[["start"]]:row[["end"]] ]))
and DF happened to be empty, I got an error about the subscripts.
Why is that? Aren't empty dataframes valid? Why does apply() with MARGIN=1 even try to do anything when there are no rows in the dataframe? Do I really need to add a condition before each such apply to make sure the dataframe isn't empty?
Thank you!
plyrones?data.frame? A list?NULL?NA?FALSE? Maybe you could eliminate emptydata.frame's earlier in your code?apply()withMARGIN=1, how exactly does it work? I thought it sends each row toFUNand aggregate the results.