• 软件
  • 怎样看到在 Rstudio 的 Rmd 文档中的那个红点是撒?

事情是酱紫的,我在使用 Rmd 文档时偶尔会遇到红点,有大神说红点是不可打印的字符,好巧不巧,我今天在将用户发来的邮件内容复制到 Rstudio Server 的 Rmd 文档时又遇到了这种红点。讲真,虽说可能只有机器能识别它,可我还是想知道怎么用人类的眼睛看到它。下面的两个文本中,其中一个里面就有红点。

```{r}
text1 <- "1. 立案责任"
print(text1)

text2 <- "1. 立案责任"
print(text2)

all.equal(text, text2)
```
[1] "1. 立案责任"
[1] "1. 立案责任"
[1] "1 string mismatch"

循例附上系统环境如下。

> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /R-4.1.3/lib64/R/lib/libRblas.so
LAPACK: /R-4.1.3/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                  LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8        LC_MONETARY=en_US.UTF-8      
 [6] LC_MESSAGES=en_US.UTF-8       LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8           LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DT_0.26           jiebaR_0.11       jiebaRD_0.1       echarts4r_0.4.4   data.table_1.14.2 RJDBC_0.2-8       rJava_0.9-13      DBI_1.1.0        

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8        pillar_1.6.4      compiler_4.1.3    later_1.3.0       tools_4.1.3       digest_0.6.29     jsonlite_1.7.3    evaluate_0.14     lifecycle_1.0.3  
[10] tibble_3.1.6      pkgconfig_2.0.3   rlang_1.1.0       shiny_1.6.0       cli_3.6.0         rstudioapi_0.13   yaml_2.2.2        xfun_0.29         fastmap_1.1.0    
[19] withr_2.5.0       stringr_1.5.0     dplyr_1.1.0       knitr_1.37        generics_0.1.0    vctrs_0.6.0       htmlwidgets_1.5.3 tidyselect_1.2.0  glue_1.6.1       
[28] R6_2.5.1          fansi_1.0.2       rmarkdown_2.10    magrittr_2.0.1    promises_1.2.0.1  ellipsis_0.3.2    htmltools_0.5.2   mime_0.12         xtable_1.8-4     
[37] httpuv_1.6.5      utf8_1.2.2        stringi_1.7.3     crayon_1.4.2  

红点似乎是随机出现的,此问题不能复现。

俺最近写代码的时候有时候也会遇到,从 console 里复制字符出来的时候也会带红点,但是忘了when and where,等哪天缘分到了,再遇到红点,俺一定努力把能复现的例子贴这

    5 天 后

    yuanfan
    施主缘分来了,俺又碰到了这个“红点” ,举个栗子¹​hair,“1”和“h”之间的红点,是个特殊字符

    > utf8ToInt('¹​hair')
    [1]  185 8203  104   97  105  114

    复现(把 R Console 拉窄一点,然后 print 变量稍多的 tibble)

    > dplyr::starwars
    # A tibble: 87 × 14
       name       height  mass hair_…¹ skin_…² eye_c…³ birth…⁴
       <chr>       <int> <dbl> <chr>   <chr>   <chr>     <dbl>
     1 Luke Skyw…    172    77 blond   fair    blue       19  
     2 C-3PO         167    75 NA      gold    yellow    112  
     3 R2-D2          96    32 NA      white,… red        33  
     4 Darth Vad…    202   136 none    white   yellow     41.9
     5 Leia Orga…    150    49 brown   light   brown      19  
     6 Owen Lars     178   120 brown,… light   blue       52  
     7 Beru Whit…    165    75 brown   light   blue       47  
     8 R5-D4          97    32 NA      white,… red        NA  
     9 Biggs Dar…    183    84 black   light   brown      24  
    10 Obi-Wan K…    182    77 auburn… fair    blue-g…    57  
    # … with 77 more rows, 7 more variables: sex <chr>,
    #   gender <chr>, homeworld <chr>, species <chr>,
    #   films <list>, vehicles <list>, starships <list>, and
    #   abbreviated variable names ¹​hair_color, ²​skin_color,
    #   ³​eye_color, ⁴​birth_year
    # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

    环境信息

    > sessionInfo()
    R version 4.1.2 (2021-11-01)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Red Hat Enterprise Linux
    
    Matrix products: default
    BLAS:   /opt/R/R_4.1.2/lib64/R/lib/libRblas.so
    LAPACK: /opt/R/R_4.1.2/lib64/R/lib/libRlapack.so
    
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
     [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
     [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
     [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
     [9] LC_ADDRESS=C               LC_TELEPHONE=C            
    [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices datasets  utils    
    [6] methods   base     
    
    loaded via a namespace (and not attached):
     [1] fansi_1.0.3      assertthat_0.2.1 utf8_1.2.2      
     [4] dplyr_1.0.10     R6_2.5.1         DBI_1.1.3       
     [7] lifecycle_1.0.3  magrittr_2.0.1   pillar_1.8.1    
    [10] rlang_1.0.6      cli_3.4.0        renv_0.13.2     
    [13] rstudioapi_0.14  vctrs_0.4.1      generics_0.1.3  
    [16] ellipsis_0.3.2   tools_4.1.2      glue_1.6.2      
    [19] purrr_0.3.4      compiler_4.1.2   pkgconfig_2.0.3 
    [22] tidyselect_1.1.2 tibble_3.1.6  

    stringr::str_view('¹​hair', use_escape = TRUE)可以显示出这个字符来,是个0宽度的空白符。

    可能是版本的问题,dplyr 1.1.4已经不在这样的情况下显示不完整的列名了。

    另一个版本/主题的差异,我的rstudio R cosole或者source code panel并不是显示成一个红点,而是一个红色方块当中一个白点。