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

pandoc.table fails with dplyr 0.7.0 / tibble 1.3.3 #300

Closed cswingle closed 7 years ago

cswingle commented 7 years ago

In the past I was able to pass a tibble to pandoc.table, but when I do that now, I get an error. It's possible this is an R 3.4.0 error, but I suspect it's something related to the new dplyr or tibble packages that came out a couple days ago. This isn't a major issue because I can always just convert the tibble to a data.frame before passing it to pandoc.table.

For example:

pandoc.table(mtcars %>% tibble::as_tibble())
Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

Session info:

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

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 utils     datasets  methods   base     

other attached packages:
 [1] pander_0.6.0    dplyr_0.7.0     purrr_0.2.2.2   readr_1.1.1    
 [5] tidyr_0.6.3     tibble_1.3.3    ggplot2_2.2.1   tidyverse_1.1.1
 [9] nvimcom_0.9-28  colorout_1.1-2 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11     cellranger_1.1.0 compiler_3.4.0   plyr_1.8.4      
 [5] forcats_0.2.0    tools_3.4.0      digest_0.6.12    jsonlite_1.5    
 [9] lubridate_1.6.0  gtable_0.2.0     nlme_3.1-131     lattice_0.20-35 
[13] rlang_0.1.1      psych_1.7.5      parallel_3.4.0   haven_1.0.0     
[17] xml2_1.1.1       stringr_1.2.0    httr_1.2.1       hms_0.3         
[21] grid_3.4.0       glue_1.1.0       R6_2.2.1         readxl_1.0.0    
[25] foreign_0.8-68   reshape2_1.4.2   modelr_0.1.0     magrittr_1.5    
[29] scales_0.4.1     rvest_0.3.2      assertthat_0.2.0 mnormt_1.5-5    
[33] colorspace_1.3-2 stringi_1.1.5    lazyeval_0.2.0   munsell_0.4.3   
[37] broom_0.4.2     
NMarkgraf commented 7 years ago

workaround:

pandoc.table(mtcars %>% tibble::as_data_frame()

;-)

Or use the current development release an push the development crew to release pander 0.7 asap or better NOW! ;-)

cswingle commented 7 years ago

@NMarkgraf Thanks. I didn't think to try the dev version, but I see at https://github.com/Rapporter/pander/blob/master/R/pandoc.R#L780 that this is what's happening inside the code.

daroczig commented 7 years ago

Yes, it was fixed in the dev version quite a long time ago, but the CRAN version is very outdated now :( Will try to push an updated in the near future.

fderyckel commented 7 years ago

devtools::install_github('Rapporter/pander') that should solve your problem

cswingle commented 7 years ago

@fderyckel Thanks. That does indeed solve my problem. Cheers.

davidski commented 7 years ago

Any chance this will be going out to CRAN in the near future? I have package updates which are blocked on this at the moment. 😢

daroczig commented 7 years ago

Ouch. I should have done that a long time ago ... Will push pander 0.7 to CRAN this weekend.

daroczig commented 7 years ago

0.6.1 was just submitted to CRAN after some R CMD check cleanups, so I hope this to be published pretty soon by the automated checks.

ChrisBeeley commented 6 years ago

EDIT THIS COMMENT WAS WRONG I WAS RUNNING AN OLD VERSION.

Just to help anyone else visiting this page, the workaround:

pandoc.table(mtcars %>% tibble::as_data_frame()

Doesn't work on my machine, but:

... removed for brevity

daroczig commented 6 years ago

@ChrisBeeley can you share your R session info? Sounds like an outdated pander version?

ChrisBeeley commented 6 years ago

I'm so sorry. You are completely right. I was sure I had the 0.6.1 version but I have now checked and I was running the older 0.6.0. Apologies. It runs fine now.