I have a dataset like this:
# test data
test.table <- data.frame(
id = seq(1,3),
sequence = c('HELLOTHISISASTRING','STRING|IS||18|LONG','SOMEOTHERSTRING!!!')
)
Each sequence has the same length (18). Now I want to create a table like this:
#id position letter
#1 1 H
#1 2 E
#1 3 L
#.....etc
Although I know I can split the strings using strsplit
, like so:
splitted <- strsplit(as.character(test.table$sequence), '')
I can't figure out how this should be converted to my preferred format?