My goal is to determine minimum runoff values ("qmin_2035") that must be sustained in rivers (to ensure that there is enough water for irrigation, industry etc.) according to given relationships for each level of the measured runoff ("q347_2035"), which here is a vector of 283 measurements. So e.g. if q347_2035 is larger than 60 and smaller/equal to 160, the minimum runoff is calculated as a fraction of q347_2035 (see in the code below):
getQMIN <- if(q347_2035 <= 60){
qMin_2035 = 50
} else if (q347_2035>60 & q347_2035 <= 160) {
qMin_2035 = 50 + (8/10)*(q347_2035 - 60)
} else if (q347_2035>=160 & q347_2035 <= 500) {
qMin_2035 = 130 + (4.4/10)*(q347_2035 - 160)
} else if (q347_2035>=500 & q347_2035 <= 2500) {
qMin_2035 = 280 + (31/100)*(q347_2035 - 500)
} else if (q347_2035>=2500 & q347_2035 < 10000) {
qMin_2035 = 900 + (21.3/100)*(q347_2035 - 2500)
} else if (q347_2035>=10000 & q347_2035 < 60000) {
qMin_2035 = 2500 + (150/1000)*(q347_2035 - 10000)
} else {
qMin_2035 = 10000
}
Now i always get error messages, saying:
Warning messages:
1: In if (q347_2035 <= 60) { :
the condition has length > 1 and only the first element will be used
2: In if (q347_2035 > 60 & q347_2035 <= 160) { :
the condition has length > 1 and only the first element will be used
3: In if (q347_2035 >= 160 & q347_2035 <= 500) { :
the condition has length > 1 and only the first element will be used
4: In if (q347_2035 >= 500 & q347_2035 <= 2500) { :
the condition has length > 1 and only the first element will be used
can anyone help to resolve the problem? Thanks a lot in advance!