Search code examples
rformattable

table does not appear when using the package formattable() in R 4.1.0 or R 4.0.3 version


I'm trying to use formatable() but I'm not successful. I'm using some examples from the official CRAN documentation, but not even the examples are running.

i try version R 4.1.0 and 4.0.3, but dont worked.

my code exemple:

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

when using the command the column information disappears enter image description here

Update:

SessionInfo()

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


Solution

  • Can you provide sessionInfo(), please? I tried to run the code, and it works fine for me.

    This is my 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   
    

    What version of formattable_0.2.1 and R Studio are you using?

    enter image description here

    Edit 1: It appears that the font is white. Can you try to edit the color of cyl, and see what happens?

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

    Edit 2: You are using an outdated R Studio version, however, the problem is related to the themes. If you are using custom themes, make sure that these does not set the font in the viewer pane as white.