Bindukumar Jampana Bindukumar Jampana - 2 months ago 12
R Question

Mean imputation of selected columns using rowMeans()

row imputations using selected columns using rowMeans(Picture)

i want to impute 4 th column to 8th column without disturbing the remaining columns.
How do i achieve this using rowMeans functionality in R
Thanks in advance.
you can find the image by clicking on picture.


Perhaps we can use na.aggregate

df1[4:8] <- lapply(df1[4:8], na.aggregate)

If we need it based on rows, use apply with MARGIN = 1

df1[4:8] <- t(apply(df1[4:8], 1, na.aggregate))