I have a list of integers that I want to sum until a threshold value is met, and then be able to access the index at which the threshold is reached.
Something like:
summing <- function(i){
sum = sum + list[i]
index = i
while(sum < thresholdValue){
summing(i++)
}}
However, I'm not well versed on writing functions in R so not 100% sure on how this should be done.