I have a dataset of two columns (we can call them x and y). I understand that for cross-validation I need to split my data into k partitions, and for that the general consensus is that I use createFolds. However, I am a little confused about the output. It seems like I can't use createFolds on my entire dataset, it seems like I have to specify something like createFolds(data$x, k=5). Then I get an output of 5 folds with a row of numbers, and I haven't been able to find documentation on what the output means exactly.
My second question is how to apply cross-validation in R to my test dataset? As I understand it, in R all I need to do to perform k-means clustering on is to specify kmeans(data, centres,...). So if I apply that command to my held-out dataset, how can I use that for cross validation on my test dataset? Thank you!