-
-
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
zero-length versus zero-width #168
Comments
I think that zero-row/length objects are useful when you want to model available observations in a given time frame and no observations are available for some securities. Apart from this, one could rule out them, like a division-by-zero error, but since they are currently legal objects, |
Another function that should be fixed for zero objects is
The result should be
could/should both name the column |
Thanks for the feedback, @steven001. There is no require(xts)
x1 <- .xts(data.frame(a=1, b=1), 1)
z1 <- as.zoo(x1)
x0 <- .xts(data.frame(a=numeric(), b=numeric()), numeric())
z0 <- as.zoo(x0)
names(x1) # [1] "a" "b"
names(z1) # [1] "a" "b"
names(x0) # NULL
names(z0) # NULL In your second example, |
This outputs whether an xts object is empty, zero-width, or zero- length, and defines each type of object. It also adds column names to the output. See #168.
It's quite common to create a zero-width xts object for aligning series or making irregular series regular. A zero-width xts object has an index, but no data.
But you can also create a "zero-length" xts object by subsetting outside the bounds of the index. For example:
Note that
str(x["1900"])
returns "An 'xts' object of zero-width", which isn't true. As you can see fromdim(x["1900"])
, the "width" is 1 but there are no rows. So I would callx["1900"]
a "zero-length xts object". It's not clear to me if/how these should be supported by other functions (e.g.merge
), but at minimumstr
shouldn't say they're zero-width xts objects.The text was updated successfully, but these errors were encountered: