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

Fixed subsetting by names, issue #110 #116

Merged
merged 3 commits into from
Apr 7, 2019
Merged

Fixed subsetting by names, issue #110 #116

merged 3 commits into from
Apr 7, 2019

Conversation

divyansh997
Copy link
Contributor

If there are columns which are present in both asset returns and weights, then we subset by name.
length(intersect(colnames(R), colnames(weights)) is needed since intersect(colnames(R), colnames(weights)) would either return a NULL or a character(0) if no columns match. character(0) can be used in an if statement by checking its length (which is 0) and this also works for NULL values(since their length are also 0).

@divyansh997
Copy link
Contributor Author

I'm sorry that the time of the commit is in the future(5 hours from now). I've fixed the time on my laptop and it should be fine for future commits.

@braverock
Copy link
Owner

weights can be a named vector as well as a timeseries, so colnames() would fail on a named vector I think.

@divyansh997
Copy link
Contributor Author

divyansh997 commented Apr 1, 2019

It seems that intersect(names(R), names(weights)) works for everything except numeric matrices, for which intersect(names(R), colnames(weights)) is required. I created explanation here

@braverock braverock merged commit f6cbd8f into braverock:master Apr 7, 2019
@divyansh997 divyansh997 deleted the develop branch April 8, 2019 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants