I have an object that has all NAs in each column after a certain number of rows. Some of the columns also have NAs prior to this point. I want to get the row index of the last row where at least one column has data in it. Here is some sample data to work with:
EDIT: For robustness, I've added NAs in the second row, following @G. Grothendieck comments. In this case, the output should still be 5.
df <- data.frame(a = 1:5, b = 6:10, c = c(1:3,rep(NA, 2)))
df <- rbind(df, rep(NA, ncol(df)), rep(NA, ncol(df)))
df[2,] <- NA
df
a b c
1 1 6 1
2 NA NA NA
3 3 8 3
4 4 9 NA
5 5 10 NA
6 NA NA NA
7 NA NA NA