2
我無法理解使用單位arg中的月份值的結果,當我在lubridate包中使用as.numeric和period時。 也許它是一個包?lubridate中的意外值as.numeric使用值月份單位arg
a <- period(years = 1, months = 3, days = 1)
as.numeric(a, 'days')
as.numeric(a, 'years')
as.numeric(a, 'months')
結果:
> as.numeric(a, 'days')
[1] 457.5625
> as.numeric(a, 'years')
[1] 1.252738
> as.numeric(a, 'months')
[1] 0.1043948
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint LMDE
locale:
[1] LC_CTYPE=es_AR.UTF-8 LC_NUMERIC=C LC_TIME=es_AR.UTF-8 LC_COLLATE=es_AR.UTF-8 LC_MONETARY=es_AR.UTF-8
[6] LC_MESSAGES=es_AR.UTF-8 LC_PAPER=es_AR.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_AR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.5.0 purrr_0.2.2 readr_1.0.0 tidyr_0.6.1 tibble_1.2
[6] ggplot2_2.2.1 tidyverse_1.1.1 pgr_0.0.9002 myutilities_0.0.0.9014 magrittr_1.5
[11] lubridate_1.6.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.9 plyr_1.8.4 forcats_0.2.0 tools_3.3.2 jsonlite_1.2 gtable_0.2.0 nlme_3.1-128
[8] lattice_0.20-34 psych_1.6.12 DBI_0.5-1 RPostgreSQL_0.4-1 parallel_3.3.2 haven_1.0.0 stringr_1.1.0
[15] httr_1.2.1 xml2_1.1.1 hms_0.3 grid_3.3.2 R6_2.2.0 readxl_0.1.1 foreign_0.8-67
[22] reshape2_1.4.2 modelr_0.1.0 scales_0.4.1 assertthat_0.1 mnormt_1.5-5 rvest_0.3.2 colorspace_1.3-2
[29] stringi_1.1.2 lazyeval_0.2.0 munsell_0.4.3 broom_0.4.1
在此先感謝
是的,你是對的。我把'as.numeric(a,「秒」)/(86400 * 365.25)/ 12 [1] 0.1043948 > as.numeric(a,「seconds」)/((86400 * 365.25)/ 12) [1] 15.03285'。非常感謝。 – Diego
不客氣。 :)我也剛剛向lubridate提交了一個包含修正的請求:https://github.com/hadley/lubridate/pull/524 –