Problems adding a month to X using POSIXlt in R - need to reset value using as.Date(X)

前端 未结 3 802
不知归路
不知归路 2020-12-22 05:14

This works for me in R:

# Setting up the first inner while-loop controller, the start of the next water year
  NextH2OYear <- as.POSIXlt(firstDate)
  Next         


        
3条回答
  •  青春惊慌失措
    2020-12-22 06:01

    Can you perhaps provide a reproducible example? What's in firstDate, and what version of R are you using? I do this kind of manipulation of POSIXlt dates quite often and it seems to work:

    Sys.Date()
    # [1] "2013-02-13"
    date = as.POSIXlt(Sys.Date())
    date$mon = date$mon + 1
    as.Date(date)
    # [1] "2013-03-13"
    

提交回复
热议问题