【发布时间】:2022-01-10 07:35:17
【问题描述】:
使用相关问题中的示例:nearest month end in R
library(lubridate)
library(dplyr)
dt<-data.frame(orig_dt=as.Date(c("1997-04-01","1997-06-29")))
dt %>% mutate(round_dt=round_date(orig_dt, unit="month"),
modified_dt=round_date(orig_dt, unit="month")-days(1))
在一个会话中,我正确地获得了四舍五入的日期(通过命名空间加载的 R 4.0.0、Rcpp_1.0.4.6)
orig_dt round_dt modified_dt
1 1997-04-01 1997-04-01 1997-03-31
2 1997-06-29 1997-07-01 1997-06-30
在另一个会话中,我得到的是地板而不是圆形(不同的机器,R 4.0.2,Rcpp 不是通过命名空间加载的)
orig_dt round_dt modified_dt
1 1997-04-01 1997-04-01 1997-03-31
2 1997-06-29 1997-06-01 1997-05-31
我认为这可能与 Rcpp 有关,因为之前我收到了一条错误消息
Error in C_valid_tz(tzone) (rscrpt.R#27): function 'Rcpp_precious_remove' not provided by package 'Rcpp'
Show stack trace
虽然我不再收到错误,但值不同,我想知道为什么/如何在不完全重新安装的情况下修复它。
【问题讨论】:
-
可能与stackoverflow.com/questions/68416435/…有关。你可以重新安装 Rcpp 看看。
-
谢谢!
Rcpp还提出了与round_date问题无关的问题,如下所述。我现在也更新了Rcpp,所以应该都修好了!