title: R caret discretization within cross validation
body: <p>I'm using R caret package and I want to apply a discretization function to all predictive variables within cross-validation.</p>
  
  <p>For example using this code:</p>
  
  <pre><code># load the library
  library(caret)
  # load the iris dataset
  data(iris)
  # define training control
  train_control &lt;- trainControl(method="cv", number=10)
  # fix the parameters of the algorithm
  grid &lt;- expand.grid(.fL=c(0), .usekernel=c(FALSE))
  # train the model
  model &lt;- train(Species~., data=iris, trControl=train_control, method="nb", tuneGrid=grid)
  # summarize results
  print(model)
  </code></pre>
  
  <p>I want to apply arules <code>discretizeDF.supervised</code> (<a href="https://www.rdocumentation.org/packages/arulesCBA/versions/1.1.4/topics/discretizeDF.supervised" rel="nofollow noreferrer">https://www.rdocumentation.org/packages/arulesCBA/versions/1.1.4/topics/discretizeDF.supervised</a>)  using only the training fold to learn the correct groups and then apply it to the test fold. I don't mind using any other library/function for discretization as long as it is supervised.</p>
  
  <p>AFAIK this is the correct way to do discretization so it must be a way to do it. I have been reading about "recipes" but I haven't been able to make it work.</p>