Hello,
What type of data do you have? A vector? Or is it a matrix, a
data.frame, a list, etc?
Suppose it is a vector named x. Then you could do something like
rate <- 0.2
is.na(x) <- sample(length(x), rate*length(x))
At an R prompt type
?is.na
?sample
Hope this helps,
Rui Barradas
Às 21:28 de 05-07-2018, Adam Z. Jabir escreveu:
Hi,
I want to simulate missing at random for my dataset. Do you know an easy way to
do it?
I want to try not to have the missing�s for the same observations. I mean if
one observation is been selected randomly to have missing I don�t want to have
all the var of the same obs missing.
I want to be able to choose rate of missing that should be applied.
Thanks,
Adam
Envoy� � partir de Outlook<http://aka.ms/weboutlook>
[[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.
______________________________________________
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.