-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Milestone
Description
'lag' is a generic function in R. Some packages extend it - for example xts does this.
So this works:
library(xts)
x=xts(1:32,order.by=seq(from=as.Date("2014-01-01"),to=as.Date("2014-02-01"),by="days"))
x
lag(x,k=4)
lag(x,k=4,na.pad=FALSE)
lag(x,4)
But if we now attach the dplyr library it does not extend the lag generic function. It replaces it with an explicit function which breaks xts functionality.
library(dplyr)
lag(x,k=4)
# Error in lag(x, k = 4) : unused argument (k = 4)
lag(x,k=4,na.pad=FALSE)
# Error in lag(x, k = 4, na.pad = FALSE) :
# unused arguments (k = 4, na.pad = FALSE)
lag(x,4)
# [1] NA NA NA NA 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# (loses xts attributes)
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.1.1 xts_0.9-7 zoo_1.7-10
loaded via a namespace (and not attached):
[1] assertthat_0.1 grid_3.0.2 lattice_0.20-24 Rcpp_0.11.0 tools_3.0.2
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior