Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seemingly a bug in justify= and rownames=1:nrow() #339

Open
cpsyctc2 opened this issue Apr 15, 2019 · 2 comments
Open

Seemingly a bug in justify= and rownames=1:nrow() #339

cpsyctc2 opened this issue Apr 15, 2019 · 2 comments

Comments

@cpsyctc2
Copy link

I use pander a lot for tables in Rmarkdown generated from Rstudio so many thanks for the package.

Here's a reproducible example I think. It may be a bit of an edge case as I do want row names when they are 1:nrow(tmpDF)

dput(tmpDF)
structure(list(companyid = c("5be03792e60b662819bb2068", "5be071e44f07bccdf1601d0e", 
"5be069ddc5ad8b5d83c1a453", "5c5d5d3f65c8f7daf974b770", "5c7e670b08263a276d43198d", 
"5c8f873bb34f572ae12bd0b3", "5c8fccf2bf6843025d207058", "5ca1b137e4e8ee864f9c8152", 
"5ca1fd523115bd8cf834fe7d", "5cab31b0bacb74464a4cba4e"), nRowsDat = c(7429L, 
7742L, 2829L, 448L, 302L, 1994L, 827L, 1634L, 441L, 18L), nUsers = c(57L, 
70L, 15L, 4L, 2L, 23L, 12L, 14L, 4L, 1L), firstDate = structure(c(17780, 
17780, 17843, 17952, 17960, 17973, 17981, 17987, 17987, 17994
), class = "Date"), lastDate = structure(c(18000, 17994, 17933, 
17961, 17988, 18000, 17999, 18000, 17999, 17994), class = "Date"), 
    daysInData = c(220, 214, 90, 9, 28, 27, 18, 13, 12, 0)), row.names = c(NA, 
-10L), class = "data.frame")
> tmpDF
                  companyid nRowsDat nUsers  firstDate   lastDate daysInData
1  5be03792e60b662819bb2068     7429     57 2018-09-06 2019-04-14        220
2  5be071e44f07bccdf1601d0e     7742     70 2018-09-06 2019-04-08        214
3  5be069ddc5ad8b5d83c1a453     2829     15 2018-11-08 2019-02-06         90
4  5c5d5d3f65c8f7daf974b770      448      4 2019-02-25 2019-03-06          9
5  5c7e670b08263a276d43198d      302      2 2019-03-05 2019-04-02         28
6  5c8f873bb34f572ae12bd0b3     1994     23 2019-03-18 2019-04-14         27
7  5c8fccf2bf6843025d207058      827     12 2019-03-26 2019-04-13         18
8  5ca1b137e4e8ee864f9c8152     1634     14 2019-04-01 2019-04-14         13
9  5ca1fd523115bd8cf834fe7d      441      4 2019-04-01 2019-04-13         12
10 5cab31b0bacb74464a4cba4e       18      1 2019-04-08 2019-04-08          0

> dim(tmpDF)
[1] 10  6

but

> pander(tmpDF, justify = "rlrrllr",row.names = 1:nrow(tmpDF)) # left over from bug reporting
Error in pandoc.table.return(res[[1]], caption = caption, digits = digits,  : 
  Wrong number of parameters (5 instead of *4*) passed: justify

> pander(tmpDF, justify = "rlrrllr")
Error in pandoc.table.return(...) : 
  Wrong number of parameters (7 instead of *6*) passed: justify

Which is correct, as it is that
pander(tmpDF, justify = "lrrllr")
works correctly.

I hope I'm not missing something. TIA, Chris

@daroczig
Copy link
Member

Thanks for the report -- this seems to be more of an issue with splitting tables, as the below works:

> pander(tmpDF[, 1:3], justify = rep('right', 4), row.names = 1:nrow(tmpDF)) 

-------------------------------------------------------
                     companyid   nRowsDat   nUsers
-------- -------------------------- ---------- --------
   **1**   5be03792e60b662819bb2068       7429       57

   **2**   5be071e44f07bccdf1601d0e       7742       70

   **3**   5be069ddc5ad8b5d83c1a453       2829       15

   **4**   5c5d5d3f65c8f7daf974b770        448        4

   **5**   5c7e670b08263a276d43198d        302        2

   **6**   5c8f873bb34f572ae12bd0b3       1994       23

   **7**   5c8fccf2bf6843025d207058        827       12

   **8**   5ca1b137e4e8ee864f9c8152       1634       14

   **9**   5ca1fd523115bd8cf834fe7d        441        4

  **10**   5cab31b0bacb74464a4cba4e         18        1
-------------------------------------------------------

> pander(tmpDF, justify = 'rrrrrrr', row.names = 1:nrow(tmpDF), split.table = Inf) 

----------------------------------------------------------------------------------------------
                     companyid   nRowsDat   nUsers    firstDate     lastDate   daysInData
-------- -------------------------- ---------- -------- ------------ ------------ ------------
   **1**   5be03792e60b662819bb2068       7429       57   2018-09-06   2019-04-14          220

   **2**   5be071e44f07bccdf1601d0e       7742       70   2018-09-06   2019-04-08          214

   **3**   5be069ddc5ad8b5d83c1a453       2829       15   2018-11-08   2019-02-06           90

   **4**   5c5d5d3f65c8f7daf974b770        448        4   2019-02-25   2019-03-06            9

   **5**   5c7e670b08263a276d43198d        302        2   2019-03-05   2019-04-02           28

   **6**   5c8f873bb34f572ae12bd0b3       1994       23   2019-03-18   2019-04-14           27

   **7**   5c8fccf2bf6843025d207058        827       12   2019-03-26   2019-04-13           18

   **8**   5ca1b137e4e8ee864f9c8152       1634       14   2019-04-01   2019-04-14           13

   **9**   5ca1fd523115bd8cf834fe7d        441        4   2019-04-01   2019-04-13           12

  **10**   5cab31b0bacb74464a4cba4e         18        1   2019-04-08   2019-04-08            0
----------------------------------------------------------------------------------------------

Will look into this more later.

@cpsyctc2
Copy link
Author

cpsyctc2 commented Apr 16, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants