Please read the help page carefully. The value returned by impute.knn() is not a list with the 'data' component but already a matrix (with two attributes)!
Regards, Yihui -- Yihui Xie <[EMAIL PROTECTED]> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Wed, Oct 29, 2008 at 10:48 PM, Jianying Li <[EMAIL PROTECTED]> wrote: > ear all, > > This is my first time using this listserv and I am seeking help from the > expert. OK, here is my question, I am trying to use impute.knn function in > impute library and when I tested the sample code, I got the error as > followingt: > > Here is the sample code: > library(impute) > data(khanmiss) > khan.expr <- khanmiss[-1, -(1:2)] > ## ## First example > ## if(exists(".Random.seed")) rm(.Random.seed) > khan.imputed <- impute.knn(as.matrix(khan.expr)) > ## ## khan.imputed$data should now contain the imputed data matrix > x<-khan.imputed$data > > Here are the results: > >> library(impute) >> data(khanmiss) >> khan.expr <- khanmiss[-1, -(1:2)] >> ## ## First example >> ## if(exists(".Random.seed")) rm(.Random.seed) >> khan.imputed <- impute.knn(as.matrix(khan.expr)) > Cluster size 2308 broken into 1448 860 > Done cluster 1448 > Done cluster 860 >> ## ## khan.imputed$data should now contain the imputed data matrix >> x<-khan.imputed$data > Error in khan.imputed$data : $ operator is invalid for atomic vectors > > It seems that khan.imputed$data is empty!! Why is that?? > > Any help is appreciated, > > Jianying Li > > ______________________________________________ > 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-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.