Hello specialist,

I have a matrix in which there are NA,0,1 and 2 in each columns.
I wanna replace NAs with special proportion of 0,1 or 2 !
for example in df<- matric(df, nrow=50, ncol=100)

If in one column the number of NAs = 10 , # of 0=50 , #of 1=25  and # of
2=15
I want to replace  5 of 10 NAs with 0 , 3 NAs with 1 and 2 NAs with 2!


I've already calculated the proportion of 0, 1 and 2 for each column, just
I don't know how to replace the number of NAs with these number (0,1,2) and
specific proportion?

Thank you very much in advance

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to