Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

"Â" in top left table corner in pander(desctable) #334

Closed dmenne closed 5 years ago

dmenne commented 5 years ago

pander(desctable::desctable(iris))

Note the redundant character in the first row

-------------------------------------------------------------------------
                                    N     %    Mean   sd     Med   IQR  
------------------------------------ ----- ---- ------ ------ ----- -----
Sepal.Length                         150                      5.8   1.3  
daroczig commented 5 years ago

I guess this is not specific to desctable, but the non-breaking space is being replaced on your computer to that strange character. Can you please confirm with something simple, such as

> pander::pander(head(mtcars), split.table = Inf)

------------------------------------------------------------------------------------------------
                    mpg    cyl   disp   hp    drat    wt     qsec    vs   am   gear   carb 
----------------------- ------ ----- ------ ----- ------ ------- ------- ---- ---- ------ ------
     **Mazda RX4**        21     6    160    110   3.9    2.62    16.46   0    1     4      4   

   **Mazda RX4 Wag**      21     6    160    110   3.9    2.875   17.02   0    1     4      4   

    **Datsun 710**       22.8    4    108    93    3.85   2.32    18.61   1    1     4      1   

  **Hornet 4 Drive**     21.4    6    258    110   3.08   3.215   19.44   1    0     3      1   

 **Hornet Sportabout**   18.7    8    360    175   3.15   3.44    17.02   0    0     3      2   

      **Valiant**        18.1    6    225    105   2.76   3.46    20.22   1    0     3      1   
------------------------------------------------------------------------------------------------

Also, pls share your sessioninfo::session_info() or devtools::session_info()?

daroczig commented 5 years ago

BTW seems to be an encoding issue somehow https://stackoverflow.com/questions/28502051/Â-character-showing-up-instead-of-nbsp

dmenne commented 5 years ago
> library(pander)
> library(desctable)
> pander(desctable(iris))

-------------------------------------------------------------------------
                                    N     %    Mean   sd     Med   IQR  
------------------------------------ ----- ---- ------ ------ ----- -----
Sepal.Length                         150                      5.8   1.3  

Sepal.Width                          150        3.1    0.44   3     0.5  

Petal.Length                         150                      4.3   3.5  

Petal.Width                          150                      1.3   1.5  

**Species**                          150                                 

    setosa       50    33                            

    versicolor   50    33                            

    virginica    50    33                            
-------------------------------------------------------------------------

> pander(head(mtcars[,1:3]), split.table = Inf)

-------------------------------------------
                    mpg    cyl   disp 
----------------------- ------ ----- ------
     **Mazda RX4**        21     6    160  

   **Mazda RX4 Wag**      21     6    160  

    **Datsun 710**       22.8    4    108  

  **Hornet 4 Drive**     21.4    6    258  

 **Hornet Sportabout**   18.7    8    360  

      **Valiant**        18.1    6    225  
-------------------------------------------

sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252

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

other attached packages: [1] shiny_1.2.0 desctable_0.1.3 pander_0.6.3

loaded via a namespace (and not attached): [1] Rcpp_1.0.0.1 pillar_1.3.1.9000 compiler_3.5.1 later_0.7.5 tools_3.5.1
[6] digest_0.6.18 jsonlite_1.6 evaluate_0.12 tibble_1.4.2 pkgconfig_2.0.2
[11] rlang_0.3.0.1 reprex_0.2.1 rstudioapi_0.8 xfun_0.4 dplyr_0.7.99.9000 [16] knitr_1.21 fs_1.2.6 tidyselect_0.2.5 glue_1.3.0 R6_2.3.0
[21] processx_3.2.1 rmarkdown_1.11 callr_3.1.0 purrr_0.2.5 clipr_0.4.1
[26] magrittr_1.5 whisker_0.3-2 ps_1.2.1 promises_1.0.1 htmltools_0.3.6
[31] rsconnect_0.8.12 assertthat_0.2.0 mime_0.6 xtable_1.8-3 httpuv_1.4.5
[36] miniUI_0.1.1.1 crayon_1.3.4
  |    

daroczig commented 5 years ago

Thanks, can you please try left justified version as well?

pander::pander(head(mtcars[,1:3]), split.table = Inf, justify = 'left')
dmenne commented 5 years ago
> pander::pander(head(mtcars[,1:3]), split.table = Inf, justify = 'left')

-------------------------------------------
                   mpg    cyl   disp  
----------------------- ------ ----- ------
**Mazda RX4**           21     6     160   

**Mazda RX4 Wag**       21     6     160   

**Datsun 710**          22.8   4     108   

**Hornet 4 Drive**      21.4   6     258   

**Hornet Sportabout**   18.7   8     360   

**Valiant**             18.1   6     225   
-------------------------------------------

Note that this behavior is new, I only re-build a report from about 1 year ago.

daroczig commented 5 years ago

Thanks! Then I think this is coming from https://github.com/MaximeWack/desctable/commit/deecc853059d06515f21d11743da1bcad7ee4189

GegznaV commented 5 years ago

Maybe related to #296? Does this patch (Rapporter/pander@06c2f65) solve the issue: install_github("Rapporter/pander@06c2f65")? On my PC (Windows 10, R 3.5.2) it did: image

dmenne commented 5 years ago

Bingo! Thanks. I close this issue, hoping that #296 will make it into pander