error tuning custom algorithm with caret r
<p>I want to tune two parameters of my custom algorithm with caret. Un parameter (lambda) is numeric and the other parameter (prior) is character. This parameter can take two values "known" or "unknown". I've tuned the algorithm with just the lambda parameter. It's okay. But when I add the character parameter (prior) gives me the following error:</p>

<blockquote>
  <p>1: In eval(expr, envir, enclos) :   model fit failed for Resample01:
  lambda=1, prior=unknown Error in mdp(Class = y, data = x, lambda =
  param$lambda, prior = param$prior,  :    object 'assignment' not found</p>
</blockquote>

<p>the error must be related with the way to specify the character parameter (prior). Here is my code: </p>

<pre><code>my_mod$parameters &lt;- data.frame(
  parameter = c("lambda","prior"),
  class = c("numeric", "character"),
  label = c("sample_length", "prior_type"))

## The grid Element

my_mod$grid &lt;- function(x, y, len = NULL){expand.grid(lambda=1:2,prior=c("unknown", "known"))}

mygrid&lt;-expand.grid(lambda=1:2,prior=c('unknown','known'))


## The fit Element

my_mod$fit &lt;- function(x, y, wts, param, lev, last, classProbs, ...){ 
  mdp(Class=y,data=x,lambda=param$lambda,prior=param$prior,info.pred ="yes")
}

## The predict Element

mdpPred &lt;- function(modelFit, newdata, preProc = NULL, submodels = NULL)
  predict.mdp(modelFit, newdata)
my_mod$predict &lt;- mdpPred

fitControl &lt;- trainControl(method = "cv",number = 5,repeats = 5)

train(x=data, y = factor(Class),method = my_mod,trControl = fitControl, tuneGrid = mygrid)
</code></pre>