【问题标题】:table does not appear when using the package formattable() in R 4.1.0 or R 4.0.3 version在 R 4.1.0 或 R 4.0.3 版本中使用包 formattable() 时不出现表格
【发布时间】:2021-06-19 13:21:17
【问题描述】:

我正在尝试使用 formatable() 但我没有成功。我正在使用官方 CRAN 文档中的一些示例,但甚至这些示例都没有运行。

我尝试了 R 4.1.0 和 4.0.3 版本,但没有成功。

我的代码示例:

library(formattable)
formattable(mtcars, list(mpg = color_bar("lightgray", proportion)))

使用命令时列信息消失

更新:

会话信息()

R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8.1 x64 (build 9600)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

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

other attached packages:
[1] dplyr_1.0.2       readxl_1.3.1      writexl_1.3.1     webshot_0.5.2    
[5] htmltools_0.4.0   formattable_0.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6      cellranger_1.1.0  pillar_1.4.6      compiler_4.0.5   
 [5] dbplyr_1.4.4      tools_4.0.5       digest_0.6.25     jsonlite_1.6.1   
 [9] evaluate_0.14     lubridate_1.7.9   lifecycle_0.2.0   tibble_3.0.1     
[13] gtable_0.3.0      lattice_0.20-41   pkgconfig_2.0.3   rlang_0.4.7      
[17] DBI_1.1.0         cli_2.0.2         rstudioapi_0.11   yaml_2.2.1       
[21] xfun_0.14         terra_1.2-10      raster_3.4-5      knitr_1.28       
[25] generics_0.0.2    vctrs_0.3.4       htmlwidgets_1.5.1 grid_4.0.5       
[29] tidyselect_1.1.0  glue_1.4.1        R6_2.4.1          fansi_0.4.1      
[33] rmarkdown_2.2     sp_1.4-2          purrr_0.3.4       ggplot2_3.3.2    
[37] blob_1.2.1        magrittr_1.5      scales_1.1.1      codetools_0.2-18 
[41] ellipsis_0.3.1    assertthat_0.2.1  colorspace_1.4-1  munsell_0.5.0    
[45] crayon_1.3.4 

formattable_0.2.1

【问题讨论】:

    标签: r formattable


    【解决方案1】:

    请提供sessionInfo()好吗?我尝试运行代码,它对我来说很好。

    这是我的sessionInfo()

    R version 4.1.0 (2021-05-18)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Pop!_OS 20.04 LTS
    
    Matrix products: default
    BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
    LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
    
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_DK.UTF-8        LC_COLLATE=en_US.UTF-8    
     [5] LC_MONETARY=en_DK.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_DK.UTF-8       LC_NAME=C                 
     [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
     [1] formattable_0.2.1 forcats_0.5.1     stringr_1.4.0     dplyr_1.0.6       purrr_0.3.4       readr_1.4.0       tidyr_1.1.3      
     [8] tibble_3.1.2      ggplot2_3.3.3     tidyverse_1.3.1  
    
    loaded via a namespace (and not attached):
     [1] tidyselect_1.1.1  xfun_0.23         bslib_0.2.4       haven_2.4.1       colorspace_2.0-1  vctrs_0.3.8       generics_0.1.0   
     [8] htmltools_0.5.1.1 yaml_2.2.1        utf8_1.2.1        rlang_0.4.11      jquerylib_0.1.4   pillar_1.6.1      glue_1.4.2       
    [15] withr_2.4.2       DBI_1.1.1         dbplyr_2.1.1      modelr_0.1.8      readxl_1.3.1      lifecycle_1.0.0   munsell_0.5.0    
    [22] gtable_0.3.0      cellranger_1.1.0  rvest_1.0.0       htmlwidgets_1.5.3 evaluate_0.14     knitr_1.33        fansi_0.4.2      
    [29] broom_0.7.6       Rcpp_1.0.6        scales_1.1.1      backports_1.2.1   jsonlite_1.7.2    fs_1.5.0          hms_1.1.0        
    [36] digest_0.6.27     stringi_1.6.2     grid_4.1.0        cli_2.5.0         tools_4.1.0       sass_0.3.1        magrittr_2.0.1   
    [43] crayon_1.4.1      pkgconfig_2.0.3   ellipsis_0.3.2    xml2_1.3.2        reprex_2.0.0      lubridate_1.7.10  assertthat_0.2.1 
    [50] rmarkdown_2.8     httr_1.4.2        rstudioapi_0.13   R6_2.5.0          compiler_4.1.0   
    

    您使用的是什么版本的formattable_0.2.1R Studio

    编辑1:字体看起来是白色的。你可以尝试编辑cyl的颜色,看看会发生什么?

    formattable(mtcars, list(mpg = color_bar("lightgray", proportion), cyl = color_text("blue", "blue")))
    

    编辑 2: 您使用的是过时的 R Studio 版本,但是问题与主题有关。如果您使用的是自定义主题,请确保这些主题不会将查看器窗格中的字体设置为白色。

    【讨论】:

    • 嗨,我做了sessinfo()。我的格式是formattable_0.2.1
    • 好的,我想我现在看到了这个问题。你的字体是白色的! :-) 您是否编辑了查看器设置?
    • 尝试更改cyl的颜色,以验证这一点。
    • 这是我的观点,是的。但是,我猜你可以通过更改 R Studio 主题来解决这个问题。尝试选项 > 外观 > 编辑器主题 > xcode! (作为一个例子)告诉我它是怎么回事,我会相应地修改我的答案。
    • 您好@Serkan,我将主题更改为xcode!,它成功了!!!!现在一切都出现了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多