title: R error on train data using caret
body: <p>When I try to train some data on a simple lm in caret it return this:</p>
  
  <pre><code>&gt; rdati&lt;-read.csv("cutDati.csv")
  &gt; 
  &gt; rdati[]&lt;-lapply(rdati, factor)
  &gt; 
  &gt; dataM=as.data.frame(rdati[])
  &gt; dataM=dataM[1:100,]
  &gt; 
  &gt; data=na.omit(dataM)
  &gt; trainIndex &lt;- createDataPartition(data$d90, p = .8,
  +                                   list = FALSE,
  +                                   times = 1)
  Warning messages:
  1: In createDataPartition(data$d90, p = 0.8, list = FALSE, times = 1) :
    Some classes have no records ( 4, 6, 7, 9, 10, 11, 14, 15, 16, 17, 20, 21, 22, 23, 25 ) and these will be ignored
  2: In createDataPartition(data$d90, p = 0.8, list = FALSE, times = 1) :
    Some classes have a single record ( 1 ) and these will be selected for the sample
  &gt; training &lt;- data[ trainIndex,]
  &gt; testing  &lt;- data[-trainIndex,]
  &gt; 
  &gt; fit &lt;- train(d90 ~ ., data = training,
  +                  method = "svmLinear",
  +                  verbose = FALSE)
  Error in `contrasts&lt;-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
    contrasts can be applied only to factors with 2 or more levels
  </code></pre>
  
  <p>d90 contain factor from -1 to 27 without 0.</p>
  
  <p>Can somebody help me? :)</p>
  
  <p>Thanks,
  Marco</p>
  
  <p>Edit:</p>
  
  <p>add some infromation</p>
  
  <pre><code>&gt; str(training$d90)
   Factor w/ 25 levels "-1","1","2","3",..: 24 2 14 4 13 6 4 4 14 6 ...
  &gt; unique(training$d90)
   [1] 26 1  13 3  12 5  27 8  -1 2 
  Levels: -1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 20 21 22 23 25 26 27
  </code></pre>
  
  <p>I discover that if i restrict the area it works.</p>
  
  <pre><code>training &lt;- data[ trainIndex,200:300]
  testing  &lt;- data[-trainIndex,200:300]
  
  fit &lt;- train(d90 ~ ., data = training,
                   method = "svmLinear",
                   verbose = FALSE)
  </code></pre>
  
  <p>I'm thinking about the problem is on the data, but what problem could be? How i can check?</p>
  
  <p>I found the problem but i don't understand how i can resolve it</p>
  
  <p>I try some combination and i saw that the bug is in column 205</p>
  
  <pre><code>&gt; unique(training[,205])
  Error in `[.data.frame`(training, , 205) : 
  undefined columns selected
  </code></pre>
  
  <p>Can you help me?</p>