Michael Chirico
2025-May-11 22:35 UTC
[Rd] Why does format.default skip dispatch for list items?
This is the documented behavior since r35262 (2005), from ?format> If x is a list, the result is a character vector obtained by applying format.default(x, ...) to each element of the listOne consequence is that we can't add "nice" printing methods for list-of-object columns in data.frames: https://github.com/eddelbuettel/rprotobuf/issues/109 library(RProtoBuf) person_desc <- P("tutorial.Person") DF <- data.frame(id = 1:2) DF$person = list(person_desc$new(name = "Me"), person_desc$new(name "You", email = "y at u.com")) DF # id person # 1 1 <S4 class ?Message? [package ?RProtoBuf?] with 2 slots> # 2 2 <S4 class ?Message? [package ?RProtoBuf?] with 2 slots> ^ from format.default, with option to make it more informative One assumes that at this point, there are back-compatibility concerns since this is the documented behavior. Is there no other option than to make the 'person' column itself an S3 class with an associated format method?
Maybe Matching Threads
- R CMD build error (RProtoBuf on windows)
- CRAN: Update protocol buffers on macOS? (for RProtoBuf)
- S4 method dispatch and namespaces: why is default method selected
- Is it advisable/possible to default on Linux to an EDITOR that actually exists?
- On RObjectTables