Date formatting MMM-YYYY

后端 未结 2 1891
耶瑟儿~
耶瑟儿~ 2021-01-24 16:51

I have a dataset with dates in following format:

Initial:

Jan-2015 Apr-2013 Jun-2014 Jan-2015 Jan-2016 Jan-2015 Jan-2016 Jan-2015 Apr-2012 Nov-2012 Jun-2         


        
2条回答
  •  孤街浪徒
    2021-01-24 17:36

    You could use as.yearmon from the zoo package for this.

    library(zoo)
    12 * (as.yearmon("Jan-2015", "%b-%Y") - as.yearmon("Feb-2014", "%b-%Y"))
    
    # result
    # [1] 11
    

提交回复
热议问题