I have a sliderinput in shinyapp, which defines how much of data to use in train/test sets of a classification problem. Right now I'm doing this to get a sample from data, where input$percentInTrain
is a value between 0 and 1:
testidx <- sample(1:nrow(dt), length(1:nrow(dt)*input$percentInTrain))
rvtrain <- dt[testidx,]
rvtest <- dt[-testidx,]
Question is: is there a better and less uglier way to do that?