Hi People,

Thus anyone have a good solution for this problem:

a database called DB.


index <- sample(1:nrow(DB), size=0.2*nrow(BD))
test <- DB[index,]
train <- DB[-index,]

One of the variables in this database contais a target variable with two
values 0 and 1.

Imagine now that i want to constraint the test data frame so the 20% of the
size of "test" has 50% of DB$target.

Imagine: n=100
DB$target = { 0=80
                           1=20}

test=20 and contain 10 random values of DB$target=1 and 10 random values of
DB$target=0.



Many Thanks,
Eliano








--
View this message in context: 
http://r.789695.n4.nabble.com/Sampling-with-Constraints-for-testing-and-training-data-tp4325530p4325530.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to