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

knitted output of skimr() summary() function looks strange #453

Closed
GegznaV opened this issue May 17, 2019 · 11 comments
Closed

knitted output of skimr() summary() function looks strange #453

GegznaV opened this issue May 17, 2019 · 11 comments

Comments

@GegznaV
Copy link

GegznaV commented May 17, 2019

I wrote skimr::skim(faithful) and knitted in a bookdown project.
The top part of the summary is strange:

image

skimr v2

@elinw
Copy link
Collaborator

elinw commented May 18, 2019

Interesting ... I hadn't tried skimr in bookdown recently. we may need to go back to hard coding two blanks at the ends of lines. Could you possibly inspect the html for that block and paste it here?

@GegznaV
Copy link
Author

GegznaV commented May 18, 2019

The issue is not Bookdown specific. It occurs in R Markdown.
Here are the files (Rmd and html):
skimr__skim_faithful.zip

Do you know, how to suppress this kind of output and get the output which is the same as in R console?
R chunk options results='markup', results='asis', and paged.print=FALSE do not have any effect. (paged.print=FALSE has effect in R Notebooks). I. e., there should be an easy way to disable "auto as-is" printing. Otherwise it is frustrating to use skim in knitted documents.

HTML code:

<table style="width:49%;">
<caption>Data summary</caption>
<colgroup>
<col width="34%"></col>
<col width="13%"></col>
</colgroup>
<tbody>
<tr class="odd">
<td align="left">Name Number of rows Number of columns</td>
<td align="left">faithful 272 2</td>
</tr>
<tr class="even">
<td align="left">Column type frequency: numeric</td>
<td align="left">2</td>
</tr>
<tr class="odd">
<td align="left">Group variables</td>
<td align="left">None</td>
</tr>
</tbody>
</table>
<p><strong>Variable type: numeric</strong></p>
<table>
<thead>
<tr class="header">
<th align="left">skim_variable</th>
<th align="right">missing</th>
<th align="right">complete</th>
<th align="right">n</th>
<th align="right">mean</th>
<th align="right">sd</th>
<th align="right">p0</th>
<th align="right">p25</th>
<th align="right">p50</th>
<th align="right">p75</th>
<th align="right">p100</th>
<th align="left">hist</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">eruptions</td>
<td align="right">0</td>
<td align="right">272</td>
<td align="right">272</td>
<td align="right">3.49</td>
<td align="right">1.14</td>
<td align="right">1.6</td>
<td align="right">2.16</td>
<td align="right">4</td>
<td align="right">4.45</td>
<td align="right">5.1</td>
<td align="left">▇▂▂▇▇</td>
</tr>
<tr class="even">
<td align="left">waiting</td>
<td align="right">0</td>
<td align="right">272</td>
<td align="right">272</td>
<td align="right">70.90</td>
<td align="right">13.59</td>
<td align="right">43.0</td>
<td align="right">58.00</td>
<td align="right">76</td>
<td align="right">82.00</td>
<td align="right">96.0</td>
<td align="left">▃▃▂▇▂</td>
</tr>
</tbody>
</table>
 

@elinw elinw changed the title knitted output of skimr() function looks strange knitted output of skimr() function looks strange in bookdown May 21, 2019
@elinw elinw changed the title knitted output of skimr() function looks strange in bookdown knitted output of skimr() function looks strange May 21, 2019
@elinw
Copy link
Collaborator

elinw commented May 21, 2019

So it looks like we need to make sure that the first rows get properly divided into <td></td> cells and possibly even <th></th>
I think the problem is in knit_print and I suspect that we will need to build the summary string differently for knitting than for use on the console.

@GegznaV
Copy link
Author

GegznaV commented Jun 9, 2019

If there is an intermediate Markdown code for tables, it may indicate incorrect formatting. Something like this where the end of column 1 is indicated incorrectly:

Header of line 1  Header of line 2
-------------- -----------------------
contents 1           contents 2
contents 1           contents 2

@elinw
Copy link
Collaborator

elinw commented Jun 16, 2019

Right, I think that one of the big inconsistencies in markdown flavors is how tables are marked up. So I bet pandoc is expecting something that is different than what rmarkdown is generating.

@elinw
Copy link
Collaborator

elinw commented Jun 16, 2019

Okay I pushed a fix for this that breaks grouped data but it is in markdown_to_pdf branch. Once I find out why the grouped data isn't working I'll make a PR. But in the meantime feel free to test. It required changing the blank lines that we had added to solid lines, I don't love this, maybe that's something that can be solved also but for now at least all the data are in the correct rows.

@elinw
Copy link
Collaborator

elinw commented Jun 16, 2019

#466 So now it works with group. I had to replace our lovely blank spaces with horizontal lines. It could be that we do that condtionally when knitting, but for now this works. @GegznaV @michaelquinn32

@elinw elinw changed the title knitted output of skimr() function looks strange knitted output of skimr() summary() function looks strange Jun 16, 2019
@GegznaV
Copy link
Author

GegznaV commented Jun 21, 2019

Now it looks much better.
Just two notes:

  1. The summary table is not centered anymore.
  2. Those lines (see red arrows), I'm not sure if they are necessary as they consume two extra lines and table gets bigger. I'm not sure if they should be removed too as they give clarity.

image

Is there an option to have a summary of variables only (without the part, that can be extracted with summary(skim(...)))? I.e., just this part (for all types of variables, if there are several):

image

@elinw
Copy link
Collaborator

elinw commented Jul 5, 2019

I'm really of mixed minds about the lines because I do feel we added them for a good reason in the prevsious version, there a clearly separate sections. But they do take up a lot of space and are kind of a pain to produce.
There's a parameter setting that says to print with no summary.
https://github.com/ropensci/skimr/blob/v2/R/skim_print.R#L26

@elinw
Copy link
Collaborator

elinw commented Jul 13, 2019

Okay I merged this into V2 as it is, we can always discuss it more. At least now it works better.
I'm surprised about how many issues we are getting about bookdown so it does seem like we should try to look at the handling there more.

@elinw
Copy link
Collaborator

elinw commented Jul 13, 2019

See #473 where I am putting all bookdown issues for now.

@elinw elinw closed this as completed Jul 13, 2019
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