Hi again,
Small typo in line 5 - should be

replace_NAs<-function(x,group_lab=c("A","B","C")) {
 for(lab in group_lab) {
  indices<-grep(lab,names(x),fixed=TRUE)
  na_indices<-is.na(x[indices])
  if(any(na_indices))
   x[indices][na_indices]<-rowMeans(x[indices],na.rm=TRUE)
 }
 return(x)
}

Jim

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to