I have the following dataset
id1<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
status<-c(1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2)
df<-data.frame(id1,status)
In df
for 40% of my observations status
is '2'.
I am looking for a function to extract a sample of 10 observations from df
while maintaining the above proportion.
I have already seen stratified random sampling from data frame in R but it is not talking about the proportions.