[R] Create DataSet with MCAR type
Michael Bedward
michael.bedward at gmail.com
Tue Oct 12 04:52:14 CEST 2010
Hello Jumlong,
I'm not sure whether by '100 records' you mean a vector of 100 values
or a matrix / data.frame of 100 rows.
For a vector or matrix X you can do this:
X[ sample( length(X), 5 ) ] <- NA
For a data.frame X you could do this:
X[ sample( nrow(X), 5 ), sample( ncol(X), 5) ] <- NA
Hope this helps,
Michael
On 12 October 2010 13:14, Jumlong Vongprasert <jumlong.ubru at gmail.com> wrote:
> Dear all
> I want to create dataset with MCAR type from my dataset.
> I have my dataset with 100 records, and I want to create dataset from this
> dataset to missing 5 records.
> How I can do it.
> THX
> Jumlong
>
> --
> Jumlong Vongprasert
> Institute of Research and Development
> Ubon Ratchathani Rajabhat University
> Ubon Ratchathani
> THAILAND
> 34000
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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