Open romainfrancois opened 1 year ago
Notably there are two issues here:
length()
method registered and use thatformat()
method if there is one available. I think RStudio does this too. So does the data viewer, right?We may be able to bypass the length()
call I mentioned in the first bullet by calling format()
and taking the length of that instead, because that should be just a simple character vector we can reliably call Rf_xlength()
on.
View(rcd)
in rstudio gives this (whatever that is):
and environment pane (list) gives:
We can top this.
I think part of that is that you need registerS3Method()
. It doesn't fix calling View()
directly on the rcd
, but if you put it in a data frame as a column then registerS3Method()
is required for the format()
method to be found correctly.
library(vctrs)
rcd <- vctrs::new_rcrd(list(x = 1:10, y = letters[1:10]), class = "mylist")
format.mylist <- function(x, ...) paste("(", field(x, "x"), ", ", field(x, "y"), ")", sep = "")
registerS3method("format", "mylist", format.mylist)
View(tibble::tibble(rcd = rcd))
Follow up to this comment: https://github.com/rstudio/positron/pull/559#discussion_r1195182114
This creates a record of size 10 with 2 fields. But the environment pane only shows the record as a boring list:
even if it has a
format()
method:Should it look more like
format(rcd)
: