Double rendering of character vectors in R notebook with rmarkdown::render()

I have run into something that is baffling me, and I feel like I must be missing something obvious.

When I print a character vector in an Rmarkdown notebook by simply putting the name of the vector (abc) in a block, this renders as expected in RStudio. But when I render the notebook with rmarkdown::render() it prints twice. Once as expected:

[1] "a" "b" "c"

and once with lots of extra space:




Using print(abc) solves the trouble and prints the same either way, but I would rather not have to do that...

Also, rendering with output_format = "html_document" renders as expected. It is only with the html_notebook output that I see this.

This does not affect numeric vectors.

A gist with a test notebook is here:

Is there an argument I should be adding to rmarkdown::render()to make it behave as RStudio does?

I have tried --vanilla and xfun::Rscript_call(), but get the same results.

I have tested this with rmarkdown 2.6 & 2.7 R 4.03 & 4.04. I feel like perhaps I didn't have this problem with earlier versions, but I can't say for certain.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

This is a known issue:

1 Like