title: Dataframe subsets retain information from parent dataframe
body: <p>I assume this is used as a feature in data.frame() but it has presented a lot of problems for evaluating training and test sets for some packages. For example if you utilize h2o for machine learning, import a dataset, and subset the dataframe based on some random sample of the data, the h2o model builder will have access to the FULL original dataframe with all factor levels and all data. As such, if you try something like h2o.predict(model,newdata=dataset[test,]) your prediction will simply copy the response in the dataset over (tested for a deep learning model). You can see the factor retention below:</p>
  
  <pre><code>y = as.factor(c("1","0","0","1"))
  X = c(5,4,3,4)
  data = data.frame(y,X)
  
  train = data[c(1,4),]
  test = data[c(2,3),]
  
  trainingData = data[train,]
  trainingData
  levels(trainingData[,1])
  [1] "0" "1"
  </code></pre>
  
  <p>Now, I've been able to solve the factor information retention, but I'm not sure how to remove information from the parent dataframe in the new subset. Anyone have any ideas?</p>
  
  <p>EDIT: For anyone who has had the factor problem, it's as simple as applying function droplevels().</p>