Skip to content


[R] Solving “unused arguments (length = 4, lambda = 0.5)” error in kernlab

I recently got this puzzling error from the kernlab package, in a script that used to work really nice before:

Error in laplacedot(length = 4, lambda = 0.5) : 
  unused arguments (length = 4, lambda = 0.5)

Switching method didn’t help, for instance with a radial basis kernel instead of the laplacian one:

Error in rbfdot(length = 4, lambda = 0.5) : 
  unused arguments (length = 4, lambda = 0.5)

Apparently someone asked that on Inside-R and Stackoverflow, but didn’t care to share their solution beyond “I figured out that it’s all because of the format xtrain and ytrain”.

Well I eventually figured that out too, it turns out xtrain must be a matrix, so the fix is as simple as changing this:
svm.kernlab.mdl = ksvm(Xtrain, as.factor(ytrain),kernel="laplacedot");
into this:
svm.kernlab.mdl = ksvm(as.matrix(Xtrain), as.factor(ytrain),kernel="laplacedot");
Of course, package maintainers could do the conversion themselves, or at least provide meaningful error messages…

I use this code in a classifier wrapper in R package mc-r, currently under development and accessible at Google Code and Bitbucket:
https://code.google.com/p/mc-r/
https://bitbucket.org/patheticcockroach/mc-r/src

Posted in R (R-project).


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Akila says

    Thanks, It worked for me

  2. Rove says

    Great! Thanks, it helped me as well



Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA