R 3.5.1中的RStudio笔记本电脑中的输出奇怪(失真) [英] Strange (distortred) output in RStudio notebook in R 3.5.1

查看:122
本文介绍了R 3.5.1中的RStudio笔记本电脑中的输出奇怪(失真)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到R 3.5.1中的RStudio 笔记本中有奇怪的行为.我可以通过使用以下代码来重现该行为:

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.

在R 3.5.1中:

此行为可能与带有R列表的此问题有关.它存在于笔记本中,如果在控制台上运行代码或编织了文档,则它会消失.在R 3.4.4中,也不存在此问题. 如果在列表和数据框之间运行其他代码,该问题也将消失,例如:

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)

我有以下问题:

  1. 我使用Windows. Linux和Mac OS用户可以重现该问题吗?
  2. 如何解释输出失真的原因?
  3. 如果我希望以后解决该问题,我应该在哪里报告?


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)  

推荐答案

看来,这是一个影响Windows上使用R 3.5.1的GUI应用程序的错误(例如RGui和RStudio).例如,您可以通过以下方式看到类似的效果:

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)

为我提供货源:

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

我们将在下一版RStudio中修复一个问题,但目前的解决方法是避免在R中打印数据帧之前先打印空列表.

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.

这篇关于R 3.5.1中的RStudio笔记本电脑中的输出奇怪(失真)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆