-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
cbind support for deparse.level #358
Comments
Can you give a reproducible example of a call to |
my real world use case leverages a utility function z <- getSymbols("SPY", auto.assign = F)
cbind(z, roc20 = ROC(Cl(z), n = 20), roc50 = ROC(Cl(z), n=50))
#> tail(cbind(z, roc20 = ROC(Cl(z), n = 20), roc50 = ROC(Cl(z), n=50)))
# Open High Low Close Volume Close.1 Close.2
#2021-Oct-08 00:00:00.000 -0600 439.48 439.89 437.19 437.86 74557404 -0.013933130 -0.003121482
#2021-Oct-11 00:00:00.000 -0600 437.16 440.26 434.62 434.69 65233285 -0.023755219 -0.005519280
#2021-Oct-12 00:00:00.000 -0600 435.67 436.10 432.78 433.62 71181163 -0.020808594 -0.005883621
#2021-Oct-13 00:00:00.000 -0600 434.71 436.05 431.54 435.18 72973979 -0.025535398 -0.010395012
#2021-Oct-14 00:00:00.000 -0600 439.08 442.66 438.58 442.50 70236825 -0.007268168 0.011216814
#2021-Oct-15 00:00:00.000 -0600 444.75 446.26 444.09 445.87 66260210 0.010075936 0.012490885 Desired Results # Open High Low Close Volume roc20 roc50
#2021-Oct-08 00:00:00.000 -0600 439.48 439.89 437.19 437.86 74557404 -0.013933130 -0.003121482
#2021-Oct-11 00:00:00.000 -0600 437.16 440.26 434.62 434.69 65233285 -0.023755219 -0.005519280
#2021-Oct-12 00:00:00.000 -0600 435.67 436.10 432.78 433.62 71181163 -0.020808594 -0.005883621
#2021-Oct-13 00:00:00.000 -0600 434.71 436.05 431.54 435.18 72973979 -0.025535398 -0.010395012
#2021-Oct-14 00:00:00.000 -0600 439.08 442.66 438.58 442.50 70236825 -0.007268168 0.011216814
#2021-Oct-15 00:00:00.000 -0600 444.75 446.26 444.09 445.87 66260210 0.010075936 0.012490885
|
the advantage the a |
One workaround is to use
The underlying issue is how |
thats great! dont know enough about r internals to know why that works. i expect about 90% + of my scenarios are univariate output
…________________________________
From: Joshua Ulrich ***@***.***>
Sent: Sunday, October 17, 2021 7:29 AM
To: joshuaulrich/xts ***@***.***>
Cc: Ethan Smith ***@***.***>; Author ***@***.***>
Subject: Re: [joshuaulrich/xts] cbind support for deparse.level (#358)
One workaround is to use drop() to remove the dimension (and column name) from the univariate objects you're binding.
The underlying issue is how merge.xts() handles column names, so it might take some time to get this changed. merge.xts() is central to the entire package's functionality, so we have to be very careful not to break things when making changes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#358 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AF2ACB7KNGSHO733CVKTHMLUHLFUJANCNFSM5FYMITAA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
im going to close this issue, as i no longer think xts should handle this differently. in fact, i think |
current
cbind.xts
does not support naming columns during the bind. this syntaxt can be very convenient vs having the capture the output followed by acolnames()<-
Desired behavior
from the base
cbind
docs:deparse.level:
integer controlling the construction of labels in the case of non-matrix-like arguments (for the default method):
deparse.level = 0 constructs no labels; the default,
deparse.level = 1 or 2 constructs labels from the argument names, see the ‘Value’ section below.
I should add that i current use a wrapper function for this so if its complicated, not worth the trouble:
which allows me to do a single line like:
The text was updated successfully, but these errors were encountered: