GegznaV
GegznaV

Reputation: 5580

Strange (distortred) output in RStudio notebook in R 3.5.1

I noticed strange behavior in RStudio notebook in R 3.5.1. I can reproduce the behavior by using this code:

list()
head(iris)

At first, an empty list should be printed. Then, if any data frame is printed in either the same or another code chunk, its values get enclosed with additional symbols (some are indicated with arrows) as in this print screen.

In R 3.5.1:

enter image description here

This behavior might be related to this issue with R lists. It is present in notebooks and disappears if the code is run a console or if the document is knitted. In R 3.4.4 this issue is also not present. If additional code is run between the list and data frame, the issue disappears as well, e.g.:

list()
1
head(iris)

I have these questions:

  1. I use Windows. Can Linux and Mac OS users reproduce the issue?
  2. How can the causes of the distortion in the output be explained?
  3. Where should I report the issue if I want it to be solved in the future?

Session info ---------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, mingw32             
 ui       RStudio (1.1.453)           
 language (EN)                        
 collate  English_United States.1252  
 tz       Europe/Helsinki             
 date     2018-07-15                  

Packages -------------------------------------------------------------------------------------------
 package   * version date       source                          
 base      * 3.5.1   2018-07-02 local                           
 compiler    3.5.1   2018-07-02 local                           
 datasets  * 3.5.1   2018-07-02 local                           
 devtools    1.13.6  2018-06-27 CRAN (R 3.5.0)                  
 digest      0.6.15  2018-01-28 CRAN (R 3.5.0)                  
 graphics  * 3.5.1   2018-07-02 local                           
 grDevices * 3.5.1   2018-07-02 local                           
 knitr       1.20.8  2018-07-07 Github (yihui/knitr@89b34a6)    
 memoise     1.1.0   2017-04-21 CRAN (R 3.5.0)                  
 methods   * 3.5.1   2018-07-02 local                           
 stats     * 3.5.1   2018-07-02 local                           
 tools       3.5.1   2018-07-02 local                           
 utils     * 3.5.1   2018-07-02 local                           
 withr       2.1.2   2018-06-28 Github (jimhester/withr@fe56f20)
 xfun        0.3     2018-07-06 CRAN (R 3.5.0)                  
 yaml        2.1.19  2018-05-01 CRAN (R 3.5.0)  

Upvotes: 0

Views: 172

Answers (1)

Kevin Ushey
Kevin Ushey

Reputation: 21285

It appears that this is a bug that affects GUI applications using R 3.5.1 on Windows (e.g. RGui and RStudio). For example, you can see a similar effect with:

x <- 1
print(list())
save(x, file = tempfile())
output <- encodeString("apple")
print(output)

Sourcing this gives, for me:

> source('~/encoding.R')
list()
[1] "\002ÿþapple\003ÿþ"

We'll have a fix in the next version of RStudio, but for now the workaround is to just avoid printing empty lists before printing data frames in R.

Upvotes: 1

Related Questions