Skip to content

gtsave() to RTF file issue when used in an Rmd file #674

Closed

Description

@twu13

If I run the code below in RStudio the resulting .rtf file is created and can be viewed by TextEdit just fine:

library(gt)
gtsave(gt(mtcars), "test.rtf")

However if I put it into an Rmd file and knit to HTML, the .rtf file that is outputted is the same but contains in addition some strange tags (!!!!!RAW-KNITR-CONTENT and RAW-KNITR-CONTENT!!!!!) that cause the file to be unreadable by TextEdit and other errors. These seem like they are placed by knitr but I can’t tell if it’s a bug or if I’m using the function incorrectly on my end?

Activity

  1. twu13 commented on Mar 22, 2022

    @twu13
    Author

    Does anyone have any suggestions for this issue? It's still happening for me. As an example, if I knit the very simple code below from an Rmd file to either PDF or HTML the test.rtf file contains the strange tags as I described before and cannot be opened:

    ---
    title: "test"
    output: html_document
    ---
    
    ```{r setup, include=FALSE}
    library(gt)
    gtsave(gt(mtcars), "test.rtf")
    
  2. jpattee commented on Jul 8, 2022

    @jpattee

    Looks like this is a continued issue - unfortunately renders the package near-unusable with my workflow. Any solutions?

  3. twu13 commented on Jul 9, 2022

    @twu13
    Author

    @jpattee I have a manual workaround where I read the file in and strip out those strange tags...

    temp <- readr::read_file("file.rtf"))
    temp_fixed <- stringr::str_replace_all(temp, "RAW-KNITR-CONTENT!!!!!|!!!!!RAW-KNITR-CONTENT", "")
    writeLines(temp_fixed, "fixed_file.rtf")
    

    Hopefully this issue can be fixed!

  4. added this to the FUTURE milestone on Aug 22, 2022
  5. changed the title [-]gtsave to rtf file issue when used in an Rmd[/-] [+]`gtsave()` to RTF file issue when used in an Rmd file[/+] on Aug 24, 2022
  6. rich-iannone commented on Dec 10, 2022

    @rich-iannone
    Member

    Fixed by #1153.

  7. self-assigned this
    on Dec 10, 2022
  8. moved this from Backlog to Done in R Markdown Team Projectson Dec 10, 2022
  9. modified the milestones: FUTURE, v0.9.0 on Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions