Row-wise mean imputation in R
You can use rowMeans with indexing.

k &lt;- which(is.na(cancer1), arr.ind=TRUE)
cancer1[k] &lt;- rowMeans(cancer1, na.rm=TRUE)[k[,1]]


Where k is an indices of the rows with NA values.