title: Error in cut (): 'x' must be numeric
body: <p>I have following dataframe: </p>
  
  <pre><code>   newdata.1
        a.0    b.0    c.0   a.1  b.1    c.1   a.3    b.3    c.3
    1  40.00 100.00  77.78  NA  88.89  97.22    NA  80.56 100.00
    2 100.00 100.00 100.00 100 100.00 100.00    NA 100.00 100.00
    3  50.00 100.00  75.00  75 100.00  86.11    NA     NA     NA
    4  66.67  59.38 100.00  NA  59.38 100.00    NA  65.63 100.00
    5  37.50 100.00  69.44  NA 100.00  94.44 41.67  83.33  63.89
    6 100.00 100.00  91.67 100 100.00  94.44 75.00 100.00  91.67
  
   dput(newdata.1) 
  
   structure(list(a.0 = c(40, 100, 50, 66.67, 37.5, 100), b.0 = c(100, 
  100, 100, 59.38, 100, 100), c.0 = c(77.78, 100, 75, 100, 69.44, 
  91.67), a.1 = c(NA, 100, 75, NA, NA, 100), b.1 = c(88.89, 100, 
  100, 59.38, 100, 100), c.1 = c(97.22, 100, 86.11, 100, 94.44, 
  94.44), a.3 = c(NA, NA, NA, NA, 41.67, 75), b.3 = c(80.56, 100, 
  NA, 65.63, 83.33, 100), c.3 = c(100, 100, NA, 100, 63.89, 91.67
  )), .Names = c("a.0", "b.0", "c.0", "a.1", "b.1", "c.1", "a.3", 
  "b.3", "c.3"), class = "data.frame", row.names = c(NA, 6L))
  &gt;
  </code></pre>
  
  <p>When I apply to this dataframe the following code, it works well: </p>
  
  <pre><code> vars&lt;-c("a","b","c")
  
    # Code 1
   res &lt;- lapply(vars ,function(i) {
   breaks &lt;- c(-Inf,unique(quantile(newdata.1 [,paste(i,1,sep=".")], na.rm=T)),Inf)
   cut(newdata.1[,paste(i, 1 ,sep=".")],breaks, na.rm=T)
    })
  
   &gt; res
   [[1]]
   [1] &lt;NA&gt;       (87.5,100] (-Inf,75]  &lt;NA&gt;       &lt;NA&gt;       (87.5,100]
   Levels: (-Inf,75] (75,87.5] (87.5,100] (100, Inf]
  
   [[2]]
   [1] (59.4,91.7] (91.7,100]  (91.7,100]  (-Inf,59.4] (91.7,100]  (91.7,100] 
   Levels: (-Inf,59.4] (59.4,91.7] (91.7,100] (100, Inf]
  
   [[3]]
   [1] (95.8,99.3] (99.3,100]  (-Inf,86.1] (99.3,100]  (86.1,94.4] (86.1,94.4]
   Levels: (-Inf,86.1] (86.1,94.4] (94.4,95.8] (95.8,99.3] (99.3,100] (100, Inf]
  </code></pre>
  
  <p>But after slight modification of the code, it does not work</p>
  
  <pre><code>#Code 2
  res &lt;- lapply(vars ,function(i) {
  breaks &lt;- c(-Inf,unique(quantile(newdata.1 [,paste(i,1,sep=".")], na.rm=T)),Inf)
  cut(newdata.1[,paste(i, 0:1 ,sep=".")],breaks, na.rm=T)
  })
  
  Error in cut.default(newdata.1[, paste(i, 0:1, sep = ".")], breaks, na.rm = T) : 
   'x' must be numeric
  </code></pre>
  
  <p>What I have made is changing <strong>"1"</strong> to <strong>"0:1"</strong> in paste () within cut () in the last line</p>
  
  <p>When I apply the both code variants to quite similar but artificial dataframe, everything works great: </p>
  
  <pre><code> varnames&lt;-c( "a.0", "b.0", "c.0", "a.1", "b.1", "c.1", "a.3", "b.3", "c.3")
  
    a &lt;-matrix (c(1,2,3,4, 5, 6, 7, 8, 9), 2, 9)
  
    colnames (a)&lt;-varnames
  
    df&lt;-as.data.frame (a)
  
    a
        a.0 b.0 c.0 a.1 b.1 c.1 a.3 b.3 c.3
   [1,]   1   3   5   7   9   2   4   6   8
   [2,]   2   4   6   8   1   3   5   7   9
  
  #Code 1
   res &lt;- lapply(vars ,function(i) {
   breaks &lt;- c(-Inf,unique(quantile(a [,paste(i,1,sep=".")], na.rm=T)),Inf)
   cut(a[,paste(i, 1 ,sep=".")],breaks, na.rm=T)
   })
  
  res
  [[1]]
  [1] (-Inf,7] (7.75,8]
  Levels: (-Inf,7] (7,7.25] (7.25,7.5] (7.5,7.75] (7.75,8] (8, Inf]
  
  [[2]]
  [1] (7,9]    (-Inf,1]
  Levels: (-Inf,1] (1,3] (3,5] (5,7] (7,9] (9, Inf]
  
  [[3]]
  [1] (-Inf,2] (2.75,3]
   Levels: (-Inf,2] (2,2.25] (2.25,2.5] (2.5,2.75] (2.75,3] (3, Inf]
  
   #Code 2
    res &lt;- lapply(vars ,function(i) {
   breaks &lt;- c(-Inf,unique(quantile(a [,paste(i,1,sep=".")], na.rm=T)),Inf)
   cut(a[,paste(i, 0:1 ,sep=".")],breaks, na.rm=T)
   })
  
   res
   [[1]]
   [1] (-Inf,7] (-Inf,7] (-Inf,7] (7.75,8]
   Levels: (-Inf,7] (7,7.25] (7.25,7.5] (7.5,7.75] (7.75,8] (8, Inf]
  
   [[2]]
   [1] (1,3]    (3,5]    (7,9]    (-Inf,1]
   Levels: (-Inf,1] (1,3] (3,5] (5,7] (7,9] (9, Inf]
  
   [[3]]
   [1] (3, Inf] (3, Inf] (-Inf,2] (2.75,3]
   Levels: (-Inf,2] (2,2.25] (2.25,2.5] (2.5,2.75] (2.75,3] (3, Inf]
  </code></pre>
  
  <p>What can be the reason for this error? How can it be fixed? 
  Thank you very much in advance. </p>