lubridate::isoyear() returns 意外输出
lubridate::isoyear() returns unexpected outputs
我正在使用 lubridate 包来处理 R 中的日期。我从 isoyear()
函数中得到了意外的 return。
library(lubridate)
isoyear("2014-12-31")
[1] 2015
year("2014-12-31")
[1] 2014
isoyear() 函数表示 2014-12-31 是 2015 年,而 2015 表示它是 2014 年。显然 year() 的 return 是我所期望的。
有人可以解释 isoyear
和 year
之间的这种行为差异吗?我想不出任何情况下我会想要 2014 年 12 月 31 日的 2015 年 return。
您必须考虑到,输出给出的是公历年份。
The ISO year number deviates from the number of the Gregorian year on, if applicable, a Friday, Saturday, and Sunday, or a Saturday and Sunday, or just a Sunday, at the start of the Gregorian year (which are at the end of the previous ISO year) and a Monday, Tuesday and Wednesday, or a Monday and Tuesday, or just a Monday, at the end of the Gregorian year (which are in week 01 of the next ISO year).
In the period 4 January–28 December and on all Thursdays the ISO year number is always equal to the Gregorian year number.
查看 12 月 29 日至 1 月 3 日期间的一些示例,其中有所不同:
library(lubridate)
isoyear(ymd("2005-01-01"))
[1] 2004
isoyear(ymd("2008-12-30"))
[1] 2009
所以这不是错误......它只是遵循 iso years.
的计算
我正在使用 lubridate 包来处理 R 中的日期。我从 isoyear()
函数中得到了意外的 return。
library(lubridate)
isoyear("2014-12-31")
[1] 2015
year("2014-12-31")
[1] 2014
isoyear() 函数表示 2014-12-31 是 2015 年,而 2015 表示它是 2014 年。显然 year() 的 return 是我所期望的。
有人可以解释 isoyear
和 year
之间的这种行为差异吗?我想不出任何情况下我会想要 2014 年 12 月 31 日的 2015 年 return。
您必须考虑到,输出给出的是公历年份。
The ISO year number deviates from the number of the Gregorian year on, if applicable, a Friday, Saturday, and Sunday, or a Saturday and Sunday, or just a Sunday, at the start of the Gregorian year (which are at the end of the previous ISO year) and a Monday, Tuesday and Wednesday, or a Monday and Tuesday, or just a Monday, at the end of the Gregorian year (which are in week 01 of the next ISO year).
In the period 4 January–28 December and on all Thursdays the ISO year number is always equal to the Gregorian year number.
查看 12 月 29 日至 1 月 3 日期间的一些示例,其中有所不同:
library(lubridate)
isoyear(ymd("2005-01-01"))
[1] 2004
isoyear(ymd("2008-12-30"))
[1] 2009
所以这不是错误......它只是遵循 iso years.
的计算