Skip to content
Prev 164975 / 398506 Next

Construct All Possible Strings from 4 Bases (ATCG)

To add on Robin Hankin's solution, if you want to generate the strings 
you can try:
f <-  function(bases, n){apply(expand.grid(rep(list(bases),n)), 1, 
paste, collapse="")}
f(c("A", "T", "C", "G"), 2)
f(c("A", "T", "C", "G"), 4)

best

Ivar
Robin Hankin wrote: