why not simply generate random index and split to a fixed number of parts?

# generate folds as a list of indices
folds <- split(sample(nrow(data), nrow(data),replace=FALSE), as.factor(1:K))
# take the first part
data[folds[[1]], ]
# take all but the first part
data[-folds[[1]], ]