I have a large table in R, which contains all the columns, all of which are NA. I want to replace each NA cell randomly with a sample number from another table, such as:
dataTable = read.csv ("my-data.csv", header = TRUE, sep = ",", Quotation = "\", dec = ".", Fill = TRUE, comment.char = "") randValues & lt; -c (0,0.3, -0.3) datatable [is.na The problem is that each cell is replaced by random number with the same randomly selected number of each cell. How to get a different number Try it
Try sample (randvaluas, amount (is.na (dataTable)), Substituted = TRUE)
guarantees that you will get many free samples because there are values of NA
, as well as allowing the same values to be randomly selected each time. (Adds sum
function to logical
output in numeric and zero)
Comments
Post a Comment