为什么没有 lubridate:::update 函数?
Why is there no lubridate:::update function?
如题所述:为什么没有这个功能?或者以不同的方式:函数的类型是什么?当我键入 ?update
时,我从 stats
包中得到了一些东西,但是有一个 lubridate 函数,如第 7 页 here 所述。似乎还有一个 lubridate:::update.Date
函数,但是我找不到该功能的任何解释。
背景:我在一个包中使用了这个函数,我只是在我使用了描述文件中的Depends:
之后才让它工作。最初我想使用 lubridate::update()
...
您需要加载 lubridate 包:
library(lubridate)
date <- now()
print(date)
new_date <- update(date, year = 2010, month = 1, day = 1)
print(new_date)
输出:
"2016-08-04 08:58:08 CEST"
"2010-01-01 08:58:08中国中欧时间"
lubridate
包提供方法lubridate:::update.Date()
和lubridate:::update.POSIXt()
。这些函数没有导出到命名空间中,但我假设,通过函数重载,当 lubridate 库是 update()
应用于 POSIX
或 Date
对象时调用它们加载。
帮助页面 ?lubridate:::update.POSIXt
提供了一些关于 lubridate
包中的 update
函数的信息:
Description
update.Date and update.POSIXt return a date with the specified
elements updated. Elements not specified will be left unaltered.
update.Date and update.POSIXt do not add the specified values to the
existing date, they substitute them for the appropriate parts of the
existing date.
Usage
## S3 method for class 'POSIXt'
update(object, ..., simple = FALSE)
帮助页面中的用法部分和示例表明这些函数不需要单独处理,因为在加载 lubridate
库时只需使用 update()
即可调用它们.
要检查这些函数,可以在控制台中键入,例如 lubridate:::update.POSIXt
(不传递参数,也没有括号)。
如题所述:为什么没有这个功能?或者以不同的方式:函数的类型是什么?当我键入 ?update
时,我从 stats
包中得到了一些东西,但是有一个 lubridate 函数,如第 7 页 here 所述。似乎还有一个 lubridate:::update.Date
函数,但是我找不到该功能的任何解释。
背景:我在一个包中使用了这个函数,我只是在我使用了描述文件中的Depends:
之后才让它工作。最初我想使用 lubridate::update()
...
您需要加载 lubridate 包:
library(lubridate)
date <- now()
print(date)
new_date <- update(date, year = 2010, month = 1, day = 1)
print(new_date)
输出:
"2016-08-04 08:58:08 CEST"
"2010-01-01 08:58:08中国中欧时间"
lubridate
包提供方法lubridate:::update.Date()
和lubridate:::update.POSIXt()
。这些函数没有导出到命名空间中,但我假设,通过函数重载,当 lubridate 库是 update()
应用于 POSIX
或 Date
对象时调用它们加载。
帮助页面 ?lubridate:::update.POSIXt
提供了一些关于 lubridate
包中的 update
函数的信息:
Description
update.Date and update.POSIXt return a date with the specified elements updated. Elements not specified will be left unaltered. update.Date and update.POSIXt do not add the specified values to the existing date, they substitute them for the appropriate parts of the existing date.
Usage
## S3 method for class 'POSIXt'
update(object, ..., simple = FALSE)
帮助页面中的用法部分和示例表明这些函数不需要单独处理,因为在加载 lubridate
库时只需使用 update()
即可调用它们.
要检查这些函数,可以在控制台中键入,例如 lubridate:::update.POSIXt
(不传递参数,也没有括号)。