title: Divide data set into 60%, 20%, 20%
body: <p>I am trying to move from 2 sets of data to 3 sets as explained in the above question. Following is the script I used:</p>
  
  <pre><code>set.seed(125)
  d &lt;- sample(x = nrow(db), size = nrow(db) * 0.60, )
  train60 &lt;-db[d, ]
  valid40 &lt;-db[-d, ]
  </code></pre>
  
  <p>Is there a way to modify the above script? I have tried to create another line: </p>
  
  <p><code>valid40 &lt;- db[-d] * 0.2</code> which did not work. </p>
  
  <p>Current dataset has several factor variables. </p>
  
  <p>I have tried using <a href="https://stackoverflow.com/a/36069362">Frank's solution here</a> on the <code>cut</code> function, but somehow I manage to get </p>
  
  <blockquote>
    <p>Error in cut.default(seq(nrow(df)), nrow(df) * cumsum(c(0, spec)),
    labels = names(spec)) : lengths of 'breaks' and 'labels' differ</p>
  </blockquote>
  
  <p>which I don't understand even after searching for help online. </p>