Thanks All,
This is how I solved the problem and working correctly.
ndays <- nrow(Wb30)
for (iday in 2:ndays) {
#Wb30$Water_Balance <- with( Wb30, cumsum(Water_Balance + Rainfall -
Evaporation ) )
# Wb30$Water_Balance <- with( Wb30, cumsum(Wb30$Water_Balance[iday-1] +
Wb30$Rainfall[i
Hi Mac,
The first entry is 0 for water balance. That means the 3rd should be zero
according to the formula.
Water balance today = Water balance yesterday + Rainfall ā Evaporation
This loop gives 5 for each date. I don't see why ?
May Rainfall Evaporation Water_Balance
1 70
If I understand the problem correctly, then Iād suggest this:
ndays <- nrow(Wb30)
for (iday in 2:ndays) {
Wb30$Water_Balance[iday] <- Wb30$Water_Balance[iday-1] +
Wb30$Rainfall[iday] - Wb30$Evaporation[iday]
Wb30$Water_Balance[iday] <- min(Wb30$Water_Balance[iday], 100)
Wb30$Water_Ba
Sorry... That last expression was backward...
Wb30$ValidWB <- with( Wb30, 0 == cumsum( Water_Balance < 0 | 100 <
Water_Balance ) )
---
Jeff NewmillerThe . . Go Live...
DCN:B
Counting chickens after they have left the coop is not going to work. If your
inputs push w outside the limits of physics then your input data are invalid.
Arbitrarily forcing w to fit in that case partially ignores the inputs
anyway... and since there are many ways for the data to be invalid yo
Dear Duncan,
Those condition should be there and also look at Rainfall and evaporation
columns.
If i change it to be like the following loop, it can't do it.
The problem is how to include those conditions and also respect the formula?
wb=c()
for (w in 1:length(Wb30$Water_Balance)){
if(w<0){
On 23/10/2014, 8:33 AM, Frederic Ntirenganya wrote:
> Dear All,
>
> I want to calculate water balance using the following formula:
> Water balance today = Water balance yesterday + Rainfall ā Evaporation
>
> This is a sample of data I am using:
>
> head(Wb30)
> May Rainfall Evaporation Water_B
7 matches
Mail list logo