title: Use regex to transform height column into total inches column
body: <p>I am trying to &quot;use regular expressions to use the height column to create a total_inches column that has the total height in inches and is recorded as a numeric variable.</p>
  <p>I came up with a solution... but I don't think it fits the task...
  (language is R)</p>
  <pre><code>bball_data$total_inches &lt;- bball_data$height %&gt;% 
    str_extract(regex(&quot;(^\\d+) (-) (\\d+$)&quot;, comments = TRUE))
  
  
  bball_data &lt;- bball_data %&gt;% separate(total_inches, c(&quot;feet&quot;, &quot;inches&quot;), &quot;-&quot;, convert = TRUE) %&gt;%
      mutate(total_inches = (12*feet + inches))
  </code></pre>
  <p>The top line is essentially useless other than using the regex... it's been about 3 hours lol what am I missing?</p>
  <p>*update...</p>
  <pre><code>bball_data$total_inches &lt;- str_replace(bball_data$height,regex(&quot;(^\\d+)(-)(\\d+$)&quot;, comments = TRUE), &quot;\\1+\\3&quot;)
  </code></pre>
  <p>this is getting me pretty close to the end result.. but as you may guess i am unable to add \1 to \3... i tried as.numeric and as.int... but neither work.. is there another way to add this replacement value?
  dput output is ...</p>
  <p>structure(list(name = c(&quot;Alaa Abdelnaby&quot;, &quot;Zaid Abdul-Aziz&quot;,
  &quot;Kareem Abdul-Jabbar&quot;, &quot;Mahmoud Abdul-Rauf&quot;, &quot;Tariq Abdul-Wahad&quot;,
  &quot;Shareef Abdur-Rahim&quot;),
  year_start = c(1991L, 1969L, 1970L, 1991L,
  1998L, 1997L),
  year_end = c(1995L, 1978L, 1989L, 2001L, 2003L,
  2008L),
  position = c(&quot;F-C&quot;, &quot;C-F&quot;, &quot;C&quot;, &quot;G&quot;, &quot;F&quot;, &quot;F&quot;),
  height = c(&quot;6-10&quot;,
  &quot;6-9&quot;, &quot;7-2&quot;, &quot;6-1&quot;, &quot;6-6&quot;, &quot;6-9&quot;),
  weight = c(240L, 235L, 225L,
  162L, 223L, 225L),
  birth_date = c(&quot;June 24, 1968&quot;, &quot;April 7, 1946&quot;,
  &quot;April 16, 1947&quot;, &quot;March 9, 1969&quot;, &quot;November 3, 1974&quot;, &quot;December 11, 1976&quot;
  ),
  college = c(&quot;Duke University&quot;, &quot;Iowa State University&quot;, &quot;University of California, Los Angeles&quot;,
  &quot;Louisiana State University&quot;, &quot;San Jose State University&quot;, &quot;University of California&quot;
  )),
  row.names = c(NA, 6L), class = &quot;data.frame&quot;)</p>