Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when subsetting xts objects if warnPartialMatch options set #231

Closed
gp2x opened this issue Mar 30, 2018 · 1 comment
Closed

Warning when subsetting xts objects if warnPartialMatch options set #231

gp2x opened this issue Mar 30, 2018 · 1 comment
Assignees
Labels

Comments

@gp2x
Copy link

gp2x commented Mar 30, 2018

Description

I run R with the options warnPartialMatchArgs, warnPartialMatchAttr, and warnPartialMatchDollar set to TRUE, in order to minimize the chances of inadvertently assigning data to the wrong variable. However, this has the effect of generating warnings in cases where, for example, a function in a package calls another function using a partial variable name, or the variable name has been lengthened since the calling function was written.

Reproducible example

options(warnPartialMatchArgs=TRUE,
             warnPartialMatchAttr=TRUE,
             warnPartialMatchDollar=TRUE)
library(xts)
test <- xts(x=seq(1:59),order.by=seq.Date(from=as.Date("2018-01-01"),to=as.Date("2018-02-28"),by=1))
test["2018-01-05/2018-02-05",]

On my machine, this results in the following warnings:

1: In (function (year = 1970, month = 1, day = 1, hour = 0, min = 0,  :
  partial argument match of 'mon' to 'month'
2: In (function (year = 1970, month = 12, day = 31, hour = 23, min = 59,  :
  partial argument match of 'mon' to 'month'

Session Info

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS: /usr/lib/libblas.so.3.8.0
LAPACK: /usr/lib/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] xts_0.10-2 zoo_1.8-1 

loaded via a namespace (and not attached):
[1] compiler_3.4.4  grid_3.4.4      lattice_0.20-35

Possible cause

Digging around in the source a bit, it looks like the functions being referred to are firstof and lastof in the file endpoints.R. In parse8601.R these functions are called and fed output from the function parse.side... it looks like the issue is that the list returned by parse.side uses "mon" and not the "month" that firstof and lastof are expecting.

I believe you could fix the warning by changing line 98 in parse8601.R from:

 mon=as_numeric(MM),

to:

 month=as_numeric(MM),

...but I'm not an expert on the codebase and I could be wrong about this.

@joshuaulrich
Copy link
Owner

Thanks for the report! You analysis of the cause is correct, and I will implement it.

@joshuaulrich joshuaulrich self-assigned this Mar 31, 2018
@joshuaulrich joshuaulrich added this to the Release 0.11-0 milestone Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants