使用lubridate库的问题

Problems in using lubridate library

我安装了 lubridate 包。 我得到以下信息:

> install.packages("lubridate")
Installing package into ‘C:/Users/aw/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/lubridate_1.5.0.zip'
Content type 'application/zip' length 650842 bytes (635 KB)
downloaded 635 KB

package ‘lubridate’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\aw\AppData\Local\Temp\RtmpuSQUFy\downloaded_packages

之后:

> library(lubridate)
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called ‘stringi’
In addition: Warning message:
package ‘lubridate’ was built under R version 3.2.3 
Error: package or namespace load failed for ‘lubridate’

感谢@Richard Scriven。 我安装了包 stringi:

install.packages("stringi")

在更新 R 时,它更新了我所有的库,但似乎在更新 lubridate 时失败了。它抱怨 glue、stringi 和 stringr 的退出状态为 1。cmd install.packages("lubridate") 正在从源代码构建库及其依赖项。但是,由于 x64 arch 中的资源不可用,其中一个依赖项失败了。解决方案是从二进制文件安装:

install.packages("glue",type="win.binary")
install.packages("stringi",type="win.binary")
install.packages("stringr",type="win.binary")
install.packages("lubridate",type="win.binary")

对于 mac 用户,请改用 mac.binary

然后我通过 运行 以下脚本测试我的 lubridate 安装:

library(lubridate)
bday <- dmy("14/10/1979")
month(bday)
#> [1] 10
wday(bday, label = TRUE)
#> [1] Sun
#> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat

year(bday) <- 2016
wday(bday, label = TRUE)
#> [1] Fri
#> Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat

Kf