Given the following example:
library(data.table)
mat <- data.table(x = c(1:10), y = c(11:20), z = c(21:30))
cut.head <- c(0, 2, 1)
cut.tail <- c(3, 1, 2)
cut.head
represents the number of rows that each column will be NA from top.
cut.tail
represents the number of rows that each column will be NA from last.
For example, if cut.head
is used, 1st and 2nd rows of column y will be NAs, as well as the 1st column of z
I would like the return as follows:
x y z
1: 1 NA NA
2: 2 NA 22
3: 3 13 23
4: 4 14 24
5: 5 15 25
6: 6 16 26
7: 7 17 27
8: NA 18 28
9: NA 19 NA
10: NA NA NA
Thank you