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

Google Summer of Code 2014 Test Implementation #62

Merged
merged 8 commits into from May 22, 2014

Conversation

RomanTsegelskyi
Copy link
Contributor

Hi,
I've implemented an S3 method for CrossTable object as a test task for GSoC2014.
It looks like it follows the standard, I will ask some questions in private e-mail.

@daroczig
Copy link
Member

Thanks, Roman. That's fine for now, please come come up with a proposal on GSoC Melange before continuing with coding here.

@daroczig
Copy link
Member

Oh, and before I forget: the percentages in the "Total" column shouldn't rather end up in the col% rows?

@RomanTsegelskyi
Copy link
Contributor Author

I've added support for keeping line breaks inside cells and added keep.line.breaks param with proper explanations. Also I've implemented S3 method for CrossTable, after figuring out how to work with line breaks.

@daroczig
Copy link
Member

Great, thanks!

I had some hard time while realizing why split.line was only called with CJK characters :) Could you please add a comment there for future reference that \n has no width or similar? So that a cell with line-breaks behaves like CJK chars from a practical point of view.

And could you please verify if this is the expected result:

> library(descr)
> library(pander)
> library(rapport)
> pander(CrossTable(ius2008$gender, ius2008$dwell))

------------------------------------------------
       city   small town   village   Total 
---------- ------ ------------ --------- -------
 **male**                                       
    N       338        28         19       385  
 Row (%)    88%        7%         5%       54%  
Column (%)  59%       90%         68%           
            54%        4%         3%            

**female**                                      
    N       234        3           9       246  
 Row (%)    95%        1%         4%       35%  
Column (%)  41%       10%         32%           
            37%        0%         1%            

  Total     572        31         28       709  
            81%        4%         4%            
------------------------------------------------

Pandoc does not keep the line breaks in the cells -- only if ""A backslash followed by a newline is also a hard line break. Note: in multiline and grid table cells, this is the only way to create a hard line break, since trailing spaces in the cells are ignored." (Pandoc manual)

This means that we have to "escape" (with a backslash) the line-breaks inside of the cells, otherwise those are deleted by Pandoc. Well, this POC test of the GSoC application is more complex than I thought before, sorry for that.

Can you address this issue? And please feel free to ping me at any time.

@RomanTsegelskyi
Copy link
Contributor Author

I've added artificial backslash symbols and fixed correct count of total. Now the example calculates and renderes correctly.
One issue, I've noticed. This implementetation will not allow simple or Rmarkdown style, because it uses line breaks inside strings and forces to keep them.
I think that this was actually a nice task for me to start with, I had to debug line by line pandoc.table to understand everything for implementation of CrossTable, so I got more understanding I think.

daroczig added a commit that referenced this pull request May 22, 2014
Google Summer of Code 2014 Test Implementation
@daroczig daroczig merged commit f437175 into Rapporter:master May 22, 2014
@daroczig
Copy link
Member

Great, thank you very mcuh! Well, simple and Rmarkdown table styles do not support line breaks, but we cannot help that.

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

Successfully merging this pull request may close these issues.

None yet

2 participants