[R] subscript out of bounds error in lda

Silvia Lomascolo slomascolo at zoo.ufl.edu
Fri Jun 15 17:47:59 CEST 2007


I work with Windows, R version 2.4.1

I'm trying to do a discriminant analysis and, in trying to figure out how to
do it following the example from R help, I'm getting an error that says
'subscript out of bounds'.  I don't know what this means and how to solve it
(I'm very new with R)

I'm doing everything in this made-up test matrix:

   group var1 var2 var3
1      1    3   55    6
2      1    4   66    7
3      1    5   55    8
4      1    4   66    7
5      1    3   44    6
6      1    4   55    5
7      2    5   88    9
8      2    4   99    8
9      2    8   88    9
10     2    9   76    8
11     2    8   66    9
12     2    9   99   10
13     2   10  100    9

I write:

data.tb<-read.table('locationHere.txt', header=T)
data.df<-as.data.frame (data.tb)                                                           
train<-sample (1:63, 30)                                                                                                                                                       
table (data.df$group[train])                                                                 
data.disc<-lda(group~., data.tb, subset = train)                                             
data.disc                                                                                    
predict (data.disc, data.df[-train,])$class              

This is where I get the message:

Error in `[.data.frame`(data.df, -train, ) : 
        subscript out of bounds

Can anyone, please help me figure out what this is about? Thanks!

Silvia.                                    
-- 
View this message in context: http://www.nabble.com/subscript-out-of-bounds-error-in-lda-tf3928773.html#a11142304
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list