[R] Working with createFolds
ruipbarradas at sapo.pt
Sun Apr 7 17:26:01 CEST 2013
You should say from what package are the functions you're using.
From the help page of createFolds, the return value is "A list or
matrix of row position integers corresponding to the training data"
So to subset use `[` or `[[`. Try
If it's a numeric vector, folds$index$Fold_i[i]
If it's a matrix, folds$index$Fold_i[i, j]
If it's a list, folds$index$Fold_i[[i]]
Hope this helps,
Em 07-04-2013 13:24, Nicolás Sánchez escreveu:
> I have a question. I am working with createFolds:
> folds<- trainControl(method='cv', index=createFolds(data$Score,list = TRUE))
> I need to iterate over folds to extract the indexes from each fold.
> For example, if I do folds$index$Fold01, it contains:
> 5 11 17 29 44 50 52 64 65
> I need to iterate over each $Fold_i to extract the indexes, but I can't do
> it because I don't know how to iterate over the structure folds$index$Fold_i
> Any ideas?
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help