How I loop over this code
list.of.results &lt;- lapply(seq(INSERT_TOTAL_NUMER_OF_SAMPLES_HERE),function(sample.id){
whichSignatures(tumor.ref = sigs.input, 
                           signatures.ref = signatures.nature2013, 
                           sample.id = sample.id, 
                           contexts.needed = TRUE,
                           tri.counts.method  = 'genome')[[1]]
})

sig &lt;- do.call(rbind,list.of.results)