split - Extract a fixed-length character in R -
i have attribute consisting dna sequences , translate amino name. need split sequence in fixed-length character 3. here sample of data
data=c("aatagacgt","tgaccc","aaatcactcttt")
how can extract into:
[1] "aat" "aga" "cgt" [2] "tga" "ccc" [3] "aaa" "tca" "ctc" "ttt"
so far can find how split string given regex separator
try
strsplit(data, '(?<=.{3})', perl=true)
or
library(stringi) stri_extract_all_regex(data, '.{1,3}')
Comments
Post a Comment