I want to replace my NA values from a matrix acquired by :
read.table(…)
Those values should be the mean of the corresponding row.
a = c(NA, 1, 2, 3, 10) a[which(is.na(a)==TRUE)] = mean(a,na.rm = T)