title: Iterate a characters or numbers in a loop in R
body: <p>Quite new to R so this may be an easy answer. 
  I have a list of characters. I want to remove the last letter and iterate it by one so A becomes B, 1 becomes 2 etc. </p>
  
  <pre><code>waferlist&lt;-c('L2MLQ','L2MIW','L2MK0','L2ML6','L2MO2','L2MHE','L2MK4','L2MN6','L2MLM')
  
  for (i in waferlist)
  {
  
  lastchar&lt;-substr(i,5,6)           #Get last character
  
  k&lt;-lastchar==LETTERS             #Is it a Letter
  
  pos&lt;-min(which(k==TRUE))        #Find letter position and itterate
  pos&lt;-pos+1
  pos&lt;-LETTERS[pos]
  </code></pre>
  
  <p>The problem I'm having is if the last character is a number, it returns it as an <code>Inf</code> or <code>NA_character_</code> as its not in LETTERS. </p>
  
  <p>I've tried to find a way to select these non results below but it doesn't see it as a <code>TRUE/FALSE</code> statement so it doesn't work. Is there another way to do this? </p>
  
  <pre><code>     if(pos==Inf | pos==NA_character_)
      {
         lastchar&lt;-as.numeric(lastchar)
         pos&lt;-lastchar+1
      }
  </code></pre>