I would need some help to understand this type of code and the action that happens here. For instance, we take a vector x defined by the integer (8,6,5,4,2,1,9).
The first step of this function would be to check if the condition is given, that the length of this vector is higher than 1. For x, the condition is given. The next step is to highlight the position of the smallest value in this vector, this is 6. But I dont understand what actually happens in the next steps and why it has to combine it as a vector?
selsort <- function(x) {
if(length(x) > 1) {
mini <- which.min(x)
c(x[mini], selsort(x[-mini])) #selsort() somewhere in here -> recursion
} else x
}