I have this function I've been able to do but I don't fully understand the code, as everything is new to me. Would be very helpful if anyone could correct me.
Here is what i think it does:
give the function the name find_maximum
maximum is the first value in the vector
for
loop which "i" will go through all the vectorsif "i" is greater than maximum, maximum will be the vector[[i]]
Then it will return maximum
#Function to find maximum
find_maximum <- function(vector){
maximum <- vector[[1]]
for (i in seq_along(vector)){
if (vector[[i]] > maximum) maximum <- vector[[i]]
}
return(maximum)
}