每天,我在R中使用date()函数创建一个新的工作文件夹,命名为今天的日期。但是,一旦我加载了lubridate包,它就不能工作。当我删除包时,date()再次工作。这样的“日期”功能有哪些不同的工作方式?在加载lubridate包时,消息如下:
Attaching package: ‘lubridate’. The following object is masked from
‘package:base’: date. 要得到今天的日期和时间,x的值应该是多少?
date() #works well
library(lubridate)
date() #does not work now. Error Msg: Error in as.POSIXlt(x, tz = tz(x)) :
#argument "x" is missing, with no default
detach("package:lubridate", unload=TRUE)
date() #now it works again without "x"发布于 2017-05-18 15:44:01
函数date()被同名为lubridate::date()的函数屏蔽。
解决办法是使用base::date()
发布于 2017-05-18 15:45:25
基本上,lubridate包含一个名为"date“的函数,所以当您加载lubridate包时,您使用的是来自该包的date()函数,而不是来自基本包的函数。
如果您想使用lubridate包中的特定函数,只需键入lubridate::"the name of the function goes here"而不加载lubridate包。
https://stackoverflow.com/questions/44052244
复制相似问题