Dear all, there is a best way to do the following task? x = rep(c("A","B"),5) y = rnorm(10) data = data.frame(x,y) data$y[1:2] = c(NA,NA) means = ave(data$y,as.character(data$x),FUN=function(x)mean(x,na.rm=T)) aux = which(is.na(data$y)) data[aux,"y"] = means[aux] _________________________________________________________________ Encontre o que procura com mais eficiência! Instale já a Barra de Ferra[[replacing trailing spam]] [[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.