R-工作室。安装 lubridate 后出错:找不到函数 "dmy_hm"

R-Studio. Error after installing lubridate: could not find function "dmy_hm"

首先我安装了 lubridate:

install.packages("lubridate") Installing package into ‘C:/Users/Llorenc  Piera/AppData/Roaming/SPB_Data/R/win-library/3.4’ (as ‘lib’ is unspecified) trying URL  'https://cran.rstudio.com/bin/windows/contrib/3.4/lubridate_1.7.4.zip' Content type 'application/zip' length 1365606 bytes (1.3 MB) downloaded 1.3 MB

package ‘lubridate’ successfully unpacked and MD5 sums checked

Warning in install.packages : cannot remove prior installation of package ‘lubridate’

然后我尝试 运行:

dmy_hm('01-01-2012 12:12')

并得到:

Error in dmy_hm("01-01-2012 12:12") : could not find function "dmy_hm"

这几周前在我的电脑上还能用,但现在不行了。

但是,如果我 运行:

lubridate::dmy_hm('01-01-2012 12:12')

我明白了

[1] "2012-01-01 12:12:00 UTC"

但是使用 'lubridate::' 对我来说不是很好,因为它在其他函数中不起作用

lubridate::dmy_hm('01-01-2012 12:12') 

表示: 运行 lubridate 包中的 dmy_hm 函数。 但你需要 library(lubridate)

如果您使用的是 Rstudio,请按照以下步骤操作:

使用更简单的选项来安装包。比如Packages -> Intall -> name of package

然后在 package 选项卡中,搜索 lubridate 并确保它已被选中。

下图显示了如何操作。