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

importDefault allows getSymbol functions to be called via namespace, … #134

Closed
wants to merge 1 commit into from

Conversation

@woodvi
Copy link

@woodvi woodvi commented Jan 11, 2017

…eg quantmod::getSymbols (instead of getSymbols)

…eg quantmod::getSymbols (instead of getSymbols)
@woodvi

This comment has been minimized.

Copy link
Owner

@woodvi woodvi commented on 2289111 Jan 11, 2017

One of the three warnings concerning this post at StackOverflow was this warning about the call stack "overflowing" (pardon the pun).

  1. a warning when using the getSymbols.sit(). and I am not sure what to do about it. Here is the warning.
 1	out of	1	Reading	SPY	03-Jan-2000	19-Jul-2016	
 Warning message:
 In if (as.character(sc[[1]]) != calling.fun) return() :
   the condition has length > 1 and only the first element will be used

I'm getting this Warning using getSymbols.FRED and getSymbols(..., src="FRED"). Like the poster, I'm getting my data, so its no surprise that this shows that the issue is known and not a priority and
this looks like this might be related to Issue joshuaulrich#61

I don't get the warning when I step thru the getSymbols.FRED code, however the offending line is in importDefaults, where importDefaults verifies the call stack. importDefaults("getSymbols.FRED") is called from getSymbols.FRED with a string constant parameter that's length exactly 1.

From stat.ethz.ch

sys.call, sys.frame and sys.function accept integer values for the argument which. Non-negative values of which are frame numbers whereas negative values are counted back from the frame number of the current evaluation.

The parameter is an indexing integer, I don't see the condition in which sc <- sys.call(-1) should be more than one item. Even if sc is more than one item, sc[[1]] would have to be a single item.

I rebuilt the source adding some "show", "str" and "dim" decorations to the importDefaults function, and the length of calling.fun is one as expected, but the length of sc is 4!

quantmod::getSymbols(Symbols = ("BAMLHYH0A0HYM2TRIV"), src = "FRED", 
    verbose = TRUE)
[1] 4
[1] "1] ::"         "1] quantmod"   "1] getSymbols"
[1] "2] ("                  "2] BAMLHYH0A0HYM2TRIV"
[1] "3] FRED"
[1] "4] TRUE"

So the deal is that the poster and I were calling getSymbols with its namespace, eg: quantmod::getSymbols, and that sys.call was putting both tokens into the first slot, but importDefaults just wants the last token in that slot.

@joshuaulrich joshuaulrich added this to the Release 0.4-10 milestone Jun 19, 2017
@joshuaulrich
Copy link
Owner

@joshuaulrich joshuaulrich commented Jun 19, 2017

Thanks for the report and the patch, but I decided to use what I think is a more robust solution. I did not like the assumption that the output from sys.call() would either be a length-1 vector (so rev() wouldn't alter it), or that "getSymbols" would be at the end of the vector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.