joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
219 stars 70 forks source link

new print() formatting breaks first/last default behavior #388

Closed ethanbsmith closed 1 year ago

ethanbsmith commented 1 year ago

Description

feature #321 has changed the behavior of head() and tail() for n >= 42. instead of printing exactly n rows, it truncates the output to just a few of the first and last rows, with an ... in between. This also happens with first() and last().

i suspect this affects other output scenarios where explicit subsetting produced more than 42 rows, though not sure how common that use case is.

Expected behavior

first and last should print exactly n rows

Minimal, reproducible example

tail(as.xts(sample_matrix), 45)

Session Info

quantmod_0.4.20.2  TTR_0.24.3.1       xts_0.12.9900      zoo_1.8-11
joshuaulrich commented 1 year ago

Actually, I don't think this is a bug or unintended behavior. Those functions still work as intended. The "problem" is that the results are auto-printed, which calls print.xts() automatically. And 40 is the default number of rows to truncate. There's no easy way for print.xts() to know what call immediately preceded it.

The solution will be to set the yet-to-be-named option to a value you prefer. I chose 40 because that's roughly what fits on my laptop screen. data.table uses 100. I'm open to suggestions for the default vaule.

ethanbsmith commented 1 year ago

didnt mean to imply it broke these functions directly. just that the effective behavior was different

anything between 55-100 for default would be my suggestion.


From: Joshua Ulrich @.> Sent: Monday, January 30, 2023 2:31 PM To: joshuaulrich/xts @.> Cc: Ethan Smith @.>; Author @.> Subject: Re: [joshuaulrich/xts] new print() formatting breaks first/last default behavior (Issue #388)

Actually, I don't think this is a bug or unintended behavior. Those functions still work as intended. The "problem" is that the results are auto-printed, which calls print.xts() automatically. And 40 is the default number of rows to truncate. There's no easy way for print.xts() to know what call immediately preceded it.

The solution will be to set the yet-to-be-named option to a value you prefer. I chose 40 because that's roughly what fits on my laptop screen. data.table uses 100. I'm open to suggestions for the default vaule.

— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjoshuaulrich%2Fxts%2Fissues%2F388%23issuecomment-1409371417&data=05%7C01%7C%7Ccaf1a9b91c2a4673c18308db03095af0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638107110937715068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OLLDZWAYQ4KzIy%2FeKSa41QEvZemFghmDtvoC2dtlgIE%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAF2ACBYN75R57KA2SFBHXZLWVAXLHANCNFSM6AAAAAAUJ2GRUY&data=05%7C01%7C%7Ccaf1a9b91c2a4673c18308db03095af0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638107110937715068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1p7mZ64gyIfr%2FbTo%2FFLE9OYIQrnUw7ib1PVl5rYdU6U%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

joshuaulrich commented 1 year ago

I bumped the default to 100 and added a global option to control it (in 701f4de28a1ed8165bb7ac89e81a2235fcb49737).