DATA = data.frame(STUDENT = c(1:3),
G1 = c(2,2,1),
G2 = c(3,5,4))
DATA1 = data.frame(STUDENT1 = c(0,1,1,0,0),
STUDENT2 = c(0,1,1,1,1),
STUDENT3 = c(1,1,1,1,0))
For each STUDENT in DATA I wish to create a new column that has 5 rows, Imagine filling all the rows with 0 but then filling in the row with a value of '1' if the row number is within the range between G1 and G2 from DATA for every student, like show in DATA1
dplyr+tidyr
data.table