[R] command to change some vars to missing into my dataset
    Rui Barradas 
    ru|pb@rr@d@@ @end|ng |rom @@po@pt
       
    Thu Jul  5 23:24:54 CEST 2018
    
    
  
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 using 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.
>
    
    
More information about the R-help
mailing list