rmachine-learningkernlab

kernelMatrix function in kernlab doesn't return anything


Am I missing something obvious? This works fine:

library(kernlab)
kernelMatrix(rbfdot(1), c(1,2,3)) 

Returning:

An object of class "kernelMatrix"
          [,1]      [,2]       [,3]
[1,] 1.00000000 0.3678794 0.01831564
[2,] 0.36787944 1.0000000 0.36787944
[3,] 0.01831564 0.3678794 1.00000000

But neither of these work, they just return nothing:

kernelMatrix(polydot(1), c(1,2,3)) 
kernelMatrix(vanilladot(), c(1,2,3))

I am using kernlab_0.9-19 (the latest).


Solution

  • It's not supposed to work with a vector, try kernelMatrix(polydot(1), as.matrix(c(1,2,3)))