[R] Get subset of n dimensional matrix

2009-10-09 Thread Mark McDowall
I want to select a subset of an array, but I want to make a function so that
it can handle any number of dimensions.

This is probably best described with an example

 x - 1:100
 dim(x) - c(10,10)
 x
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]1   11   21   31   41   51   61   71   8191
 [2,]2   12   22   32   42   52   62   72   8292
 [3,]3   13   23   33   43   53   63   73   8393
 [4,]4   14   24   34   44   54   64   74   8494
 [5,]5   15   25   35   45   55   65   75   8595
 [6,]6   16   26   36   46   56   66   76   8696
 [7,]7   17   27   37   47   57   67   77   8797
 [8,]8   18   28   38   48   58   68   78   8898
 [9,]9   19   29   39   49   59   69   79   8999
[10,]   10   20   30   40   50   60   70   80   90   100

 vList - vector(list, 2)
 vList[[1]] - c(4:6)
 vList[[2]] - c(4:6)
 x[vList[[1]],vList[[2]]]
 [,1] [,2] [,3]
[1,]   34   44   54
[2,]   35   45   55
[3,]   36   46   56

but if:

 x - 1:1000
 dim(x) - c(10,10,10)

I would would have to increase the returning call:
x[vList[[1]],vList[[2]],vList[[3]]]

What I would like to be able to do is pass x the list of lists and have it
return the required points.

Anyone have any clues on how to get over this hurdle?

Thank you

Mark

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Kernlab - Splinedot Kernel

2009-07-28 Thread Mark McDowall

   Hi,
   I am trying to use the splinedot kernel as part of the kernlab package, but
   I get the following error:

 Error in votematrix[i, ret  0] - votematrix[i, ret  0] + 1 :
   NAs are not allowed in subscripted assignments

   The parameters that I have used to build the model are:

 SVMmodel   -  ksvm(Classification~.,  data=dsTrain,  type=C-svc,
 kernel=splinedot, C=1)

   My training set does not contain NAs and all of the values range between 0
   to 1.
   I am using R version 2.7.0.
   If  anyone  has used ksvm with the splinedot kernel, any tips would be
   greatfully accepted.
   Mark

-- 
Mark McDowall
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.