Hello, This is the code that is giving me problems>library(boot) >data<-read.table("test",header=FALSE,sep="\t",row.names=1) >dataV2 V3 V4 A 5 8 9 B 12 54 89 C 65 89 23 D 32 69 44 E 21 84 97 F 33 59 71 G 16 45 93 H 2 46 55 I 22 33 88>resample <- function(x,index) {sample(data,replace=TRUE) } dist<-boot(data,resample,R=1000) Erreur : nombre d'indices incorrect sur la matrice (french) Error: number of indices wrong in the matrix (moreless) Can anybody help???
Your 'resample' function is not written according to the help page. Try resample <- function(x, index) { x[index, ] } -roger david v wrote:> Hello, > This is the code that is giving me problems > > >>library(boot) >>data<-read.table("test",header=FALSE,sep="\t",row.names=1) >>data > > V2 V3 V4 > A 5 8 9 > B 12 54 89 > C 65 89 23 > D 32 69 44 > E 21 84 97 > F 33 59 71 > G 16 45 93 > H 2 46 55 > I 22 33 88 > > >>resample <- function(x,index) { > > sample(data,replace=TRUE) > } > dist<-boot(data,resample,R=1000) > Erreur : nombre d'indices incorrect sur la matrice (french) > Error: number of indices wrong in the matrix (moreless) > > Can anybody help??? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/
What are you trying to do? boot does the resampling for you so you should pass the statistic that you want calculated on the resamples. Read the helpfile regarding the format of the statistic. It should take two arguments, one of which is a vector of indices specifying the resample. On Tue, 20 Dec 2005, david v wrote:> Hello, > This is the code that is giving me problems > > >library(boot) > >data<-read.table("test",header=FALSE,sep="\t",row.names=1) > >data > V2 V3 V4 > A 5 8 9 > B 12 54 89 > C 65 89 23 > D 32 69 44 > E 21 84 97 > F 33 59 71 > G 16 45 93 > H 2 46 55 > I 22 33 88 > > >resample <- function(x,index) { > sample(data,replace=TRUE) > } > dist<-boot(data,resample,R=1000) > Erreur : nombre d'indices incorrect sur la matrice (french) > Error: number of indices wrong in the matrix (moreless) > > Can anybody help??? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- ------------------------------------------------------------------ | Angelo J. Canty Email: cantya at mcmaster.ca | | Mathematics and Statistics Phone: (905) 525-9140 x 27079 | | McMaster University Fax : (905) 522-0935 | | 1280 Main St. W. | | Hamilton ON L8S 4K1 |