So, this is the question:
"Create a function that given one word, return the position of word’s letters on letters vector. For example, if the word is ‘abba’, the function will return 1 2 2 1."
What I have so far is this:
l <- function(word) {
chr <- c()
y <- c()
strsplit(chr,word)
i<-1
while(i<length) {
o<-letters[i]
x<-chr[i]
if(o==x) {
y[i]<-i
}
i+1
}
y
}
I have tried running l("hello") and it returns NULL. I'm very lost and would appreciate any help! Thank you!