Fill missing value based on probability of occurrence
问题 This is what my data.table/dataframe looks lke library(data.table) dt <- fread(' STATE ZIP PA 19333 PA 19327 PA 19333 PA NA PA 19355 PA 19333 PA NA PA 19355 PA NA ') I have three missing values in the ZIP column. I want to fill the missing values with nonmissing sample values of ZIPs according to their probability of occuring in the dataset. So for example ZIP 19333 occurs three times in the dataset and ZIP 19355 occurs twice in the dataset and 19327 occurs once. So ZIP 19333 has 50%