You could create a set of random indices for the training set and then select all but those indices for the test set, like this:
data <- c(1,3,8,7,19,5,4,10,11,20)
i <- sample(1:length(data), 5)
training <- data[i]
test <- data[-i]
This will get five points for the training set and all the remaining points will go in the test set.