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

孤街浪徒 提交于 2019-12-13 03:14:37

问题


First I installed 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’

Then I try to run:

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

and get:

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

This used to work in my computer a few weeks ago, but not any more.

Howerver, if I run:

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

I get

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

But using 'lubridate::' is not good for me since it does not work inside other functions


回答1:


The

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

means: run the dmy_hm function from lubridate package. but you need to have the library(lubridate)

if you are using Rstudio, then follow these steps:

Use easier options to install a package. Such as Packages -> Intall -> name of package

Then in the package tab, and search for the lubridate and make sure it is checked.

The below image shows how to do it.



来源:https://stackoverflow.com/questions/52003727/r-studio-error-after-installing-lubridate-could-not-find-function-dmy-hm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!