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

[Feature]: Customize data.frame output #207

Open
andrewheiss opened this issue May 22, 2024 · 2 comments
Open

[Feature]: Customize data.frame output #207

andrewheiss opened this issue May 22, 2024 · 2 comments
Labels
t: feature-request Request the addition of a new feature
Milestone

Comments

@andrewheiss
Copy link

Feature Description

In {learnr}, the results from printing data.frame output are shown as paged tables by default (using rmarkdown::paged_table(), I think)

Screenshot 2024-05-22 at 16 40 50

 

I've tried to recreate something similar with {quarto-webr}, but something along the way isn't working, and I'm not sure what.

---
title: "Testing"
format: html
engine: knitr
filters:
  - webr
webr:
  packages:
    - rmarkdown
---

```{webr-r}
#| context: setup
print.data.frame <- function(x, ...) {
  cat("This should be paged?\n")
  rmarkdown::paged_table(x)
}
```

```{webr-r}
# Implicit print doesn't use print.data.frame()
mtcars
```

```{webr-r}
# Explicit print does use print.data.frame(), but it's not paged
print(mtcars)
```
image image

 

I don't know if it's currently possible to do this with {quarto-webr}, but it would be nice!

@andrewheiss andrewheiss added the t: feature-request Request the addition of a new feature label May 22, 2024
@coatless
Copy link
Owner

The short gist: This isn't likely to happen anytime soon.

The longer gist:

I think some extra markup is happening with the rmarkdown::print.page_df() and knitr::asis_output() functions that assumes rendering from a static source.

Other hiccups relate to the meta dependencies being unable to be added to the document as we're past the render stage. Though, I think the dependencies themselves assume that the document is opened with the data embedded as the output from rmarkdown::paged_html_table() consists of a div with a script tag containing dumped data.

On {quarto-webr}'s end, we'd need the results: asis mode to avoid marking up content instead of only allowing it to pass through. c.f. #166

@coatless coatless added this to the Future milestone May 22, 2024
@andrewheiss
Copy link
Author

Ok cool cool, I'll just live with the default data.frame and tibble-based print()s. In my actual use case, I ended up showing the data frame that learners are working with using a separate, normal {r} chunk with a paged data frame, so they can still navigate the larger dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: feature-request Request the addition of a new feature
Projects
None yet
Development

No branches or pull requests

2 participants