2

I need convert strings like string below to list.

a = "ATTCCGGAACTTAA" ##string
b = list("A","T","T","C","C","G","G","A","A","C","T","T","A","A"). ##list
zx8754
  • 52,746
  • 12
  • 114
  • 209
user11847566
  • 31
  • 1
  • 1
  • 3
  • 2
    What have you tried so far? There are other similar posts on SO—which ones have you checked that haven't helped? – camille Nov 04 '19 at 21:05
  • 5
    Does this answer your question? [Split a character vector into individual characters? (opposite of paste or stringr::str\_c)](https://stackoverflow.com/questions/23028885/split-a-character-vector-into-individual-characters-opposite-of-paste-or-strin) – camille Nov 04 '19 at 21:10

2 Answers2

4

An option is to split with strsplit and convert to list with as.list

as.list(strsplit(a, "")[[1]])
akrun
  • 874,273
  • 37
  • 540
  • 662
2

You can try it with utf8ToInt and intToUtf8:

b <- Map(intToUtf8, as.list(utf8ToInt(a)))
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81