Convert String Characters to List in R

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

2

2 Answers

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

as.list(strsplit(a, "")[[1]])

You can try it with utf8ToInt and intToUtf8:

b <- Map(intToUtf8, as.list(utf8ToInt(a)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest