我有一个问题,在某些时间设置工作日的缩写数据 . 我需要的是缩写“周一,周二,周三,周四,周五,周六,周日” . 我使用的lubridate :: wday()函数给出了“Mon,Tue,Wed,Thu,Fri,Sat,Sun”的值 .
对于“星期二”和“星期四”的日子来说,这是一个小小的差异 .
x <- seq(Sys.Date() - 7, Sys.Date(), by = 1)
lubridate::wday(x, label = TRUE)
## [1] Thu Fri Sat Sun Mon Tue Wed Thu
我还使用语言环境更改了语言设置,但这并没有成功,因为我不确定要设置的可能参数(可能的选择) .
lubridate::wday(x, label = TRUE, locale = "French")
## [1] jeu\\. ven\\. sam\\. dim\\. lun\\. mar\\. mer\\. jeu\\.
lubridate::wday(x, label = TRUE, locale = "English")
## [1] Thu Fri Sat Sun Mon Tue Wed Thu
lubridate::wday(x, label = TRUE, locale = "English_Great Britain")
## [1] Thu Fri Sat Sun Mon Tue Wed Thu
lubridate::wday(x, label = TRUE, locale = "English_United States")
## [1] Thu Fri Sat Sun Mon Tue Wed Thu
差异可能来自我的R版本(现在3.4.2)的变化,因为有人提到这个新版本有关此主题的更改...(https://cran.r-project.org/bin/windows/base/NEWS.R-3.4.2.html - >在Sys.setlocale()中设置LC_ALL类别无效任何缓存的特定于语言环境的日/月名称和strptime()的AM / PM指示符(因为设置LC_TIME自R 3.1.0起)
系统 - 信息:
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.2 imsbasics_1.8.0 magrittr_1.5 tools_3.4.2 simtimer_2.0.18 Rcpp_0.12.12 lubridate_1.7.1
[8] schedule_1.0.0 stringi_1.1.5 stringr_1.2.0
1 回答
由于您需要非标准缩写,因此您需要手动执行:
我不确定你为什么认为这与R版本有关...