I have a input stream of cleaned letters that I want to convert into a vector of numbers from 1 to 27 (all letters including space). I can't imagine a nested for loop is the best way to do this though. Is it possible without the loops?
space_letters = append(letters, " ")
text_to_numbers = function (input_stream) {
input_stream = unlist(strsplit(input_stream, split = ""))
for(i in 1:length(input_stream)) {
for(j in 1:length(space_letters) {
if(input_stream[i] == space_letters[j]) {
input_stream[i] = j
}
}
}
return(as.integer(input_stream))
}