I want to create a new dataframe which removes all NAs from the top of each column. The resulting data frame will have n-maxNA rows, n is the size of the original data frame, maxNA is the max NA length for all columns. Here is a reproducible example.
This is the input
structure(list(X1 = c(NA, NA, NA, NA, 7L, 0L, 6L, 1L, 9L, 6L),
X2 = c(NA, NA, 1L, 10L, 2L, 9L, 1L, 8L, 4L, 1L), X3 = c(NA,
NA, NA, NA, NA, 6L, 8L, 6L, 9L, 8L), X4 = c(7L, 4L, 1L, 5L,
10L, 0L, 7L, 5L, 2L, 7L)), row.names = c(NA, -10L), class = "data.frame")
And the result should look like this
structure(list(x1 = c(7L, 0L, 6L, 1L, 9L), x2 = c(1L, 10L, 2L,
9L, 1L), x3 = c(6L, 8L, 6L, 9L, 8L), x4 = c(7L, 4L, 1L, 5L, 10L
)), class = "data.frame", row.names = c(NA, -5L))