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

Fix rendering of character vectors #443

Open
jashapiro opened this issue Mar 15, 2021 · 2 comments
Open

Fix rendering of character vectors #443

jashapiro opened this issue Mar 15, 2021 · 2 comments

Comments

@jashapiro
Copy link
Member

There seems to be a bug (or at least behavior unexpected to me) with Rmarkdown::render() that results in character vectors printing oddly when called on their own. You can see this at the following htmlpreview link:
https://htmlpreview.github.io/?https://github.com/AlexsLemonade/training-modules/blob/7517d4d1b1d288fe8920e337ee8f21c0d71db8fe/RNA-seq/02-gastric_cancer_tximeta.nb.html#file-names

In particular, the character vector prints twice, once with no quotes and lots of space. I have posted a couple places to see if there is a quick fix, but have gotten no response as yet.

Originally posted by @jashapiro in #441 (comment)

A potential workaround is to use print(myvector) instead of bare myvector when we want to show a character vector, but this might be a pain to explain, and does not matter for general use, so I would rather not do this. Hopefully a solution will be proposed somewhere.

My Stack Overflow posting

@jashapiro
Copy link
Member Author

jashapiro commented Mar 16, 2021

Another possible option: use html_document for the rendering script instead of html_notebook, as this does not have the odd behavior. This will result in *.html files rather than *.nb.html, so we would have a lot of links to update. (I don't want to change the extension, even though that would be easier, as they won't be true notebook documents).

To keep the formatting the same, we can use the following block in the make-live script:

 # Rerender notebooks if --render is TRUE
if (render) {
  knitr::opts_chunk$set(comment = NA)
  nbformat = rmarkdown::html_document(toc = TRUE, toc_float = TRUE, highlight = "textmate")
  rmarkdown::render(opt$notebook, 
                    output_format = nbformat,
                    quiet = TRUE)
}

@jashapiro
Copy link
Member Author

It is a known issue... and old.
rstudio/rmarkdown#1568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant