-1

i am trying to vectorize this function in r to compute a sparse matrix but I have been faced with this error invalid 'type' (list) of argument, what am i doing wrong?
P.S: I don't want to use forloop
This is a dataset to test
fam <- structure(list(ID = c(1L, 2L, 3L, 4L, 6L, 5L, 7L), dad = c(0L...