Dear all, Is there 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 você procura com mais eficiência! Instale já a Barra de Ferramentas com Windows Desktop Search! É GRÁTIS! _________________________________________________________________ Veja mapas e encontre as melhores rotas para fugir do trânsito com o Live Search Maps! [[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.