2

So, im reading words from the keyboard creating like a sequence of letters (aminoacids), e.g "AAAA" or "ATWRN".

first.sqnc <- readline(prompt = "Insert the first sequence ") #Read first sequence
first.sqnc = "ARTC"

But now i need to access to each of the letters separetly. Because later on i need do search on a matrix the value in the colunm "A" and the row "T" and i cant because i dont know how to separate the letters from each other.

In C we can read character by character and put it on a vector. How do we do that in R?

N3R4ZZuRR0
  • 2,400
  • 4
  • 18
  • 32
Bert
  • 25
  • 3
  • 1
    Possible duplicate of [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 Sep 27 '19 at 16:26

1 Answers1

1

We can use strsplit to split a the blank to create a list of length 1, extract ([[) the list element

strsplit(first.sqnc, "")[[1]]
akrun
  • 874,273
  • 37
  • 540
  • 662