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).


5 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

  3. gerda says

    Thanks for this

  4. Alex says

    Thank you Thank you Thank you!!! I was reading through the other post that you mentioned and found it unhelpful because of the lack of explanation at the end. Your post here was a life-saver!

  5. Saurav says

    Thanks that was really helpful.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA