set.seed(101) 
genome <- paste(sample(c("A", "C", "T", "G"), 1000, replace = TRUE), collapse = "")我需要从上面的序列中创建50个片段。我试着使用for循环,但是没能弄清楚。请帮帮忙。我是R编程的新手。
基因组由20个基因组成,每个基因的长度为50个碱基。基因组的前50个碱基对应于基因1,后50个碱基对应于基因2,依此类推。
发布于 2015-03-10 13:34:31
你可以试试
 res1 <- strsplit(genome, '(?<=.{50})', perl=TRUE)[[1]]
 nchar(res1)
 #[1] 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50或者使用stringi
 library(stringi)
 res2 <- stri_extract_all_regex(genome, '.{1,50}')[[1]]https://stackoverflow.com/questions/28956169
复制相似问题