Bindukumar Jampana Bindukumar Jampana - 1 year ago 111
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.

Answer Source

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))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download