[R] split data with missing data condition
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Fri Oct 15 15:00:46 CEST 2010
you can do the following:
mat <- cbind(x = runif(15, 50, 70), y = rnorm(15, 2))
mat[sample(15, 2), "x"] <- NA
na.x <- is.na(mat[, 1])
mat[na.x, ]
mat[!na.x, ]
I hope it helps.
Best,
Dimitris
On 10/15/2010 2:45 PM, Jumlong Vongprasert wrote:
> Dear all
> I have data like this:
> x y
> [1,] 59.74889 3.1317081
> [2,] 38.77629 1.7102589
> [3,] NA 2.2312962
> [4,] 32.35268 1.3889621
> [5,] 74.01394 1.5361227
> [6,] 34.82584 1.1665412
> [7,] 42.72262 2.7870875
> [8,] 70.54999 3.3917257
> [9,] 59.37573 2.6763249
> [10,] 68.87422 1.9697770
> [11,] 19.00898 2.0584415
> [12,] 60.27915 2.5365194
> [13,] 50.76850 2.3943836
> [14,] NA 2.2862790
> [15,] 39.01229 1.7924957
>
> and I want to spit data into two set of data, data set of nonmising and
> data set of missing.
> How I can do this.
> Many Thanks.
> Jumlong
>
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/
More information about the R-help
mailing list