What does lubridate mean to mark the "method with signature" Timespan # Timespan selected for the function "% /%" means?

When I run the following code in R, I get a weird note (it only appears the first time the code is run in a session):

> library(lubridate)
Attaching package: ā€˜lubridateā€™
The following object is masked from ā€˜package:baseā€™:
    date
Warning message:
package ā€˜lubridateā€™ was built under R version 3.3.2 
> data.frame(i = interval(ymd(20140101), ymd(20160101)))$i %/% years(1)
Note: method with signature ā€˜Timespan#Timespanā€™ chosen for function ā€˜%/%ā€™,
  target signature ā€˜Interval#Periodā€™.
  "Interval#ANY", "ANY#Period" would also be valid
[1] 2

I am twice confused:

  • I don't understand what the alternative syntax is: a recommendation. A # is a comment in R, so a hash is supposedly used to mean something other than a hash, but what?
  • Does this tell me that I am doing something wrong? The note seems to say that it is FYI, but FYI is a strange thing that can be spit out of a function if there is no problem.
+6
source share
1 answer

, , , , .

, 2014-201-201 2 , , 4, 2016 366 . , , - , , ( , ).

( , ), , %/% %/%.

, .

data.frame(i = interval(ymd(20140101), ymd(20160101)))$i %/% years(1)
Note: method with signature ā€˜Timespan#Timespanā€™ chosen for function ā€˜%/%ā€™,
 target signature ā€˜Interval#Periodā€™.
 "Interval#ANY", "ANY#Period" would also be valid
[1] 2
data.frame(i = interval(ymd(20140101), ymd(20160101)))$i %/% years(1)
[1] 2

, . .

+3

Source: https://habr.com/ru/post/1015547/


All Articles