
Good day, 
 
A function is used on a database with 50 rows and 200 collumns. every row is 1 seperate study that the function should run through. Desired outcome are [x,y] and a weight for that coordinate.
 
I have problems with generating x.  
 
## Generating random time or x coordinate (through random time of displacement - random recall)
## First generating random time within recall period
randomrecall<-round(runif(n=1,min=recallmin,max=recallmax))
 
## Second generating random time of displacement
todrange<-todmax-todminrandomtod<-0for(i in 1:todrange){if (proprand>data[[9+i]] & proprand<=data[[10+i]]) randomtod=i}
 
Following messages are given:
 
Warning messages:1: In 1:todrange :  numerical expression has 50 elements: only the first used2: In if (proprand > data[[9 + i]] & proprand <= data[[10 + i]]) randomtod = i :  the condition has length > 1 and only the first element will be used3: In if (proprand > data[[9 + i]] & proprand <= data[[10 + i]]) randomtod = i :  the condition has length > 1 and only the first element will be used4: In if (proprand > data[[9 + i]] & proprand <= data[[10 + i]]) randomtod = i :  the condition has length > 1 and only the first element will be used5: In if (proprand > data[[9 + i]] & proprand <= data[[10 + i]]) randomtod = i :  the condition has length > 1 and only the first element will be used6: In if (proprand > data[[9 + i]] & proprand <= data[[10 + i]]) randomtod = i :  the condition has length > 1 and only the first element will be used7: In if (proprand > data[[9 + i]] & proprand <= data[[10 + i]]) randomtod = i :  the condition has length > 1 and only the first element will be used
#Thusx<-randomtod-randomrecall
----------------------------------------------------------------------------------
Question:
1. how to avoid the warning messages and make the function use all 50 elements?
    x will now go through the first row, because it uses the first element, giving only 1 outcome. But I would like it to give 50, just like the        other variables in the function. How can I do that?

Thank you,
Akko 





_________________________________________________________________


	[[alternative HTML version deleted]]

