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

fuse does not work for quote #38

Closed
ben-schwen opened this issue Oct 19, 2024 · 2 comments
Closed

fuse does not work for quote #38

ben-schwen opened this issue Oct 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ben-schwen
Copy link

ben-schwen commented Oct 19, 2024

Hey! Thanks for the great package. So far, it's quite nice to use!

We are trying to switch from rendering our vignettes with markdown and knitr to litedown.

This seems to work fine for most of our vignette except for the programming one where it fails at
https://github.com/Rdatatable/data.table/blob/200d6572b4687f3bfd555d933b0de4272f885eab/vignettes/datatable-programming.Rmd#L133-L138

Below also a reprex:

litedown::fuse('x<-1;quote(x)')
# <pre><code class="language-r">x&lt;-1;quote(x)
# </code></pre>
# <pre><code>#&gt; [1] 1
# </code></pre
litedown::fuse('quote(x)')
# Error in (function (x, ...)  : object 'x' not found

OT: is there an option to render tables with fuse like below? I couldn't come up with the right option from reactor()...

iris
#      Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
#             <num>       <num>        <num>       <num>    <fctr>
#   1:          5.1         3.5          1.4         0.2    setosa
#   2:          4.9         3.0          1.4         0.2    setosa
#   3:          4.7         3.2          1.3         0.2    setosa
#   4:          4.6         3.1          1.5         0.2    setosa
#   5:          5.0         3.6          1.4         0.2    setosa
# ---
# 146:          6.7         3.0          5.2         2.3 virginica
# 147:          6.3         2.5          5.0         1.9 virginica
# 148:          6.5         3.0          5.2         2.0 virginica
# 149:          6.2         3.4          5.4         2.3 virginica
# 150:          5.9         3.0          5.1         1.8 virginica
@yihui yihui added the bug Something isn't working label Oct 20, 2024
@yihui
Copy link
Owner

yihui commented Oct 20, 2024

This is a bug in the xfun::record(). Fixed in the dev version of xfun now. Thanks for the report!

OT: is there an option to render tables with fuse like below? I couldn't come up with the right option from reactor()...

For now, there isn't. fuse()'s default behavior is to print at most 10 rows by default (as a Markdown table). It doesn't print out the mode/class of each column below the column header, though.

  • If you want the exact printing behavior of data.table:::print.data.table and want the result to be a table, you can register an S3 method on xfun::record_print (data.table doesn't have to import xfun).
  • If you only want console output and not a table, you can bypass the table via
    ```{r, print=xfun:::record_print.default}
    data.table::as.data.table(iris)
    ```
    

@ben-schwen
Copy link
Author

Thanks for the quick response and the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants