[R] Construct All Possible Strings from 4 Bases (ATCG)

Robin Hankin rksh1 at cam.ac.uk
Wed Dec 17 10:08:00 CET 2008


Gundala

f <-  function(n){expand.grid(rep(list(seq_len(4)),n))}


HTH

Robin


Gundala Viswanath wrote:
> Dear all,
>
> Is there an efficient  way in R  to construct all  strings from 4 bases (ATCG).
> If we want a length L string,  there are 4 ^ L possible strings of such.
>
> e . g with L = 2 we have AA, AT, AC, AG, .. GC, GA, GT, GG as many as
> 4 ^ 2 = 16 strings,
> with L = 3 we have as many as 4 ^ 3 = 64 strings
>
>
> - Gundala Viswanath
> Jakarta - Indonesia
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   


-- 
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877



More information about the R-help mailing list