[R] about adding a column for water year

lily li chocold12 at gmail.com
Tue Jul 4 20:31:55 CEST 2017


Hi R users,
I have a question about adding a column for water year. The dataframe has
the structure below. But the wyear column just shows one year. Could anyone
help me with this problem? Thanks.

DF
year   month   day      time            flow
1972      1         1    1972-01-01       5
1972      1         2    1972-01-02       5.5
1972      1         3    1972-01-03       6
...
1985     12       31   1985-12-31       6


for(i in 1972:1985){
    if(DF$year==i & DF$month %in% 1:9){
      DF$wyear <- i {
    }else{
      DF$wyear < i-1
    }
  }
}

	[[alternative HTML version deleted]]



More information about the R-help mailing list