title: R use gsub as substr
body: <p>I'm using H2O for some distributed computing work (via the <code>h2o</code> package in R).  Many of the base R functions are present but I'm unable to find a suitable substitute for the <code>substr</code> function.  I do have access to the <code>sub</code> and <code>gsub</code> functions and was hoping to possibly use some form of regex as a workaround.</p>
  
  <p>I'm using the following code but not having any luck:</p>
  
  <pre><code>    df1 &lt;- data.frame(id = 1:10, var1 = seq(14102201,14103200, 100))
      df1$var2 &lt;- substr(df1$var1, 1,6)
      df1$var3 &lt;- gsub('\\d{1,8}','\\d{1,6}', df1$var1)
      df1
  </code></pre>
  
  <p>The output in <code>df1$var2</code> is what I'm looking for.  Any suggestions?</p>
  
  <p>EDIT:
  Running this code:</p>
  
  <pre><code>library(h2o)
  localH2O = h2o.init(nthreads = 2) 
  df1 &lt;- data.frame(id = 1:10, var1 = seq(14102201,14103200, 100))
  df1.hex &lt;- as.h2o(localH2O , df1)
  df1.hex$var2 &lt;- substr(df1.hex$var1, 1, 6)
  </code></pre>
  
  <p>Gets this message:</p>
  
  <pre><code>&gt; df1.hex$var2 &lt;- substr(df1.hex$var1, 1, 6)
  Error in as.character.default(x) : 
    no method for coercing this S4 class to a vector
  </code></pre>