R change integer to three integers

前端 未结 3 1809
闹比i
闹比i 2021-01-23 01:35

I have this number

20101213 which is a representation of this data 2010 Dec 13th I want to extract the year, month and day numbers from that nu

3条回答
  •  悲哀的现实
    2021-01-23 01:50

    If you don't want to deal with string representation you could also just use mod function like this:

    # using mod
    year  = floor(value/10000)
    month = floor((value %% 10000)/100)
    day = value %% 100
    

    Which will then extract the relevant parts of the number as expected.

提交回复
热议问题