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

Dynamically determine number of sub-second digits to print #405

Open
joshuaulrich opened this issue Sep 6, 2023 · 0 comments
Open

Dynamically determine number of sub-second digits to print #405

joshuaulrich opened this issue Sep 6, 2023 · 0 comments
Assignees
Labels
enhancement Enhancement to existing feature

Comments

@joshuaulrich
Copy link
Owner

Currently, the number of sub-second values printed depends on the digits.secs global option or the tformat attribute on the xts object being printed. By default, no sub-second digits are printed.

It would be nice if the number of sub-second digits that exist were printed by default. All these example should print with 6 digits because that's the largest (10.000001).

y <- structure(1:10, dim = c(10L, 1L),
    index = structure(c(1.0001, 2.002, 3.03, 4, 5, 6, 7, 8, 9, 10.000001),
                      tclass = c("POSIXct", "POSIXt"), tzone = ""),
    class = c("xts", "zoo"), dimnames = list(NULL, "y"))

print(y, show.rows = 3, max.rows = 5)  # no sub-second digits
##                      y
## 1969-12-31 18:00:01  1
## 1969-12-31 18:00:02  2
## 1969-12-31 18:00:03  3
##                 ...   
## 1969-12-31 18:00:08  8
## 1969-12-31 18:00:09  9
## 1969-12-31 18:00:10 10
 
print(y, show.rows = 3, max.rows = 5)  # 3 sub-second digits
##                          y
## 1969-12-31 18:00:01.000  1
## 1969-12-31 18:00:02.001  2
## 1969-12-31 18:00:03.030  3
##                     ...   
## 1969-12-31 18:00:08.000  8
## 1969-12-31 18:00:09.000  9
## 1969-12-31 18:00:10.000 10

options(digits.secs = 6)
print(y, show.rows = 3, max.rows = 5)  # 6 sub-second digits
##                             y
## 1969-12-31 18:00:01.000100  1
## 1969-12-31 18:00:02.001999  2
## 1969-12-31 18:00:03.030000  3
##                        ...   
## 1969-12-31 18:00:08.000000  8
## 1969-12-31 18:00:09.000000  9
## 1969-12-31 18:00:10.000002 10

options(digits.secs = op_ds)
@joshuaulrich joshuaulrich added the enhancement Enhancement to existing feature label Sep 6, 2023
@joshuaulrich joshuaulrich self-assigned this Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to existing feature
Projects
None yet
Development

No branches or pull requests

1 participant