I have a vector of random letters and I am trying to find out where they spell a word pass. let is the vector with a bunch of random letters in it. I have began with the for (i in 1:length(let)){ if(let[i] =="p") and I am unsure what to do after this.If you guys could give me some advice on what to do I would appreciate it.
            Asked
            
        
        
            Active
            
        
            Viewed 22 times
        
    0
            
            
        - 
                    1It would be easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and the desired output. – MrFlick Oct 04 '17 at 17:26
- 
                    1`& let[i + 1] == "a"`... – Gregor Thomas Oct 04 '17 at 17:27
1 Answers
0
            
            
        results<-c()
for (i in 1:length(let)) { 
  if(let[i] =="p"
     & let[i+1] =="a"
     & let[i+2] =="s"
     & let[i+3] =="s"){
    results[i] <- TRUE
  } else {results[i] <- FALSE
  }
}
 
    
    
        Alex P
        
- 1,574
- 13
- 28
