calculating number of days between 2 columns of dates in data frame

后端 未结 5 1469
轮回少年
轮回少年 2020-12-02 12:56

I have a data frame which has two columns of dates in the format yyyy/mm/dd. I am trying to calculate the number of days between these two dates for each observation within

5条回答
  •  天涯浪人
    2020-12-02 13:50

    You could find the difference between dates in columns in a data frame by using the function difftime as follows:

    df$diff_in_days<- difftime(df$datevar1 ,df$datevar2 , units = c("days"))
    

提交回复
热议问题