[R] random samples

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Thu Jan 13 14:04:06 CET 2005


try this:

S. <- A[!A%in%S]

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: <nicolas.deig at epfl.ch>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, January 13, 2005 1:50 PM
Subject: [R] random samples


> hi,
> I am encoutering a very little problem that seemed to be so easy to 
> solve....
> I need to divide the array
>
>> A<-c(1:200)
>
> into two subsets at random. Therefore I use the function "sample" in 
> R:
>
>> S<-sample(A,100)
>
> for a random sample of size 100. Then I need the values in A that 
> are not
> selected in S to be put in another array, there is my problem!
> Is there anyway to do this with a function of R or should I do one 
> by myself?
>
> Thanks in advance
> Nicolas
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list