If I understand correctly, you are trying to create a test sample. This is usually done using probabilities. Therefore, if you have n.rows samples and you want the training.fraction part of the training.fraction be used for training, you can do something like this:
select.training <- runif(n=n.rows) < training.fraction data.training <- my.data[select.training, ] data.testing <- my.data[!select.training, ]
If you want to tell EXACT the number of training cases, you can do something like:
indices.training <- sample(x=seq(n.rows), size=training.size, replace=FALSE)
source share