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

allow vectorized input in r2rtf::rtf_title, r2rtf::rtf_footnote etc #98

Closed
elong0527 opened this issue May 10, 2022 · 5 comments
Closed

Comments

@elong0527
Copy link
Collaborator

The argument in r2rtf::rtf_title should allow vectorized argument. For example:

rtf_title(    
  title = c(       "Sponsor name",       "Table xx.yy.zz"     ),     
  text_justification = c("l", "c")   )
@elong0527
Copy link
Collaborator Author

Below is an ad-hoc solution, but will need to improve it after addressing #88

library(r2rtf)

# Hard coding using RTF syntax
head(iris) %>% 
  rtf_title(title = c("{\\pard\\ql Sponsor name\\par}", "Table xx.yy.zz"),     
            text_justification = c("c")   ) %>% 
  rtf_body() %>%
  rtf_encode() %>%
  write_rtf("tmp1.rtf")

# Customize a text within paragraph.
text <- r2rtf:::rtf_paragraph(r2rtf:::rtf_text("Sponsor name"), justification = "l")
head(iris) %>% 
  rtf_title(title = c(text, "Table xx.yy.zz"),     
            text_justification = c("c")   ) %>% 
  rtf_body() %>%
  rtf_encode() %>%
  write_rtf("tmp2.rtf")

@nanxstats
Copy link
Collaborator

It would also be great if we can cover these cases in the unit tests.

@panchalh
Copy link

Thanks Yilong, suggested temporary solution of text within paragraph works beautifully to make some titles left justified and center others in the same output.
There is another issue I want to report. In so far how I have used r2rtf, the titles and footnotes created in this package using rtf_title() and rtf_footnote() functions write titles and footnotes in the body of rtf page. By comparison, SAS titles and footnotes go in to the header and footer section of rtf page. Is there a option in r2rtf package to make the titles, footnotes go to the header and footer sections of rtf respectively?

Thank you

rtf_header_body_footer__data_Sashelp_dot_Class

@elong0527
Copy link
Collaborator Author

@elong0527
Copy link
Collaborator Author

Fixed in #100

Example code:

head(iris) %>% 
  rtf_title(title = c("abc", "Table xx.yy.zz"),     
            text_justification = c("l", "c")   ) %>% 
  rtf_body() %>%
  rtf_encode() %>%
  write_rtf("tmp1.rtf")

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

3 participants