I am using mapply to find the sum of a range of indices for all cases:
score = mapply(function(x, y, z) sum(df[x, y:z]), seq_len(nrow(df)), df$index, df$index+10)
How can I add a ifelse statement to mapply so that it only applies the function if df$index >5, else the sum is 0?
Aucun commentaire:
Enregistrer un commentaire