title: Plot string kernel svm/decision boundary using kernlab
body: <p>I am using kernlab to learn the basics of kernel SVMs, and am running into some difficulty plotting the results for the model applied to the reuters dataset. </p>
  
  <p>Jean-Philippe Vert has written an excellent tutorial which I am following (<a href="http://members.cbio.mines-paristech.fr/~jvert/svn/tutorials/practical/stringkernels/stringkernels.R" rel="nofollow noreferrer">http://members.cbio.mines-paristech.fr/~jvert/svn/tutorials/practical/stringkernels/stringkernels.R</a>), but I would like to modify it to include a plot of the actual decision boundary, not just the error. My code looks like this:</p>
  
  <pre><code>library(kernlab)
  data(reuters)
  
  y &lt;- rlabels
  x &lt;- reuters
  
  kmax &lt;- 20
  errspectrum &lt;- numeric(kmax)
  errboundrange &lt;- numeric(kmax)
  
  for (k in seq(kmax)) {
    cat('.')
    sk &lt;- stringdot(type="spectrum", length=k, normalized=TRUE)
    svp &lt;- ksvm(x,y,kernel=sk,scale=c(),cross=5)
    plot(svp, data = x, main = k)
    errspectrum[k] &lt;- cross(svp)
    sk &lt;- stringdot(type="boundrange", length=k, normalized=TRUE)
    svp &lt;- ksvm(x,y,kernel=sk,scale=c(),cross=5)
    errboundrange[k] &lt;- cross(svp)    
  }
  </code></pre>
  
  <p>They key line is <code>plot(svp, data = x, main = k)</code>- I would like to plot something like this: <a href="https://github.com/topepo/caret/issues/337" rel="nofollow noreferrer">https://github.com/topepo/caret/issues/337</a> but I receive the following error: </p>
  
  <p><code>Error in sub[, 2] : subscript out of bounds</code></p>
  
  <p>I'm sure this is something silly on my part but I couldn't find a solution. Any tips would be  much appreciated. Thanks!</p>