title: Identifying consonants/vowels in R string
body: <p>Can't seem to find an answer for this.</p>
  
  <p>I have written some R code to extract a substring from a longer string, taking every character left of the '.' from the original string, as below.</p>
  
  <pre><code>dataframe1[["column"]] &lt;- gsub("\\..*","",dataframe2$variable)
  </code></pre>
  
  <p>This works fine, no problem. <strong>NOTE</strong> the resultant substrings are of variable length between 5-7 chars.</p>
  
  <p>I now need to find a way of evaluating whether each character in said string is a consonant or a vowel.</p>
  
  <p>I had achieved this previously using sqldf as follows;</p>
  
  <pre><code>   ("SELECT char1||char2||char3||char4||char5 as pattern
              FROM
                  (SELECT CASE WHEN substr(var,1,1) IN ('a','e','i','o','u') THEN 'V' ELSE 'C' END as char1  
                  ,CASE WHEN substr(var,2,1) IN ('a','e','i','o','u') THEN 'V' ELSE 'C' END as char2  
                  ,CASE WHEN substr(var,3,1) IN ('a','e','i','o','u') THEN 'V' ELSE 'C' END as char3
                  ,CASE WHEN substr(var,4,1) IN ('a','e','i','o','u') THEN 'V' ELSE 'C' END as char4
                  ,CASE WHEN substr(var,5,1) IN ('a','e','i','o','u') THEN 'V' ELSE 'C' END as char5 
       FROM some_table WHERE len = '5L')")
  </code></pre>
  
  <p>This would give me something like: </p>
  
  <p>ABBCD || VCCCC</p>
  
  <p>ABABE || VCVCV</p>
  
  <p>AEEBC || VVVCC</p>
  
  <p>etc etc...</p>
  
  <p>The problem is this is totally inelegant and woefully inefficient, particularly as, as mentioned, the length of the var is between 5-7 chars.
  I also want to avoid incorporating sqldf as I've found it makes performing base R functions on the dataframe later difficult in certain situations.</p>
  
  <p>So, can you please advise as to how I can achieve this using R and importantly, using a method that works irrespective of char length?</p>