Coder Social home page Coder Social logo

atorus-research / pharmartf Goto Github PK

View Code? Open in Web Editor NEW
32.0 32.0 6.0 2.46 MB

Enhanced RTF wrapper written in R for use with existing R tables packages such as huxtable or GT

Home Page: https://atorus-research.github.io/pharmaRTF/

License: Other

R 100.00%

pharmartf's People

Contributors

ashley-tarasiewicz avatar elimillera avatar mstackhouse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pharmartf's Issues

Add option for text color

Hello,

Thank you for the great package. I have been using it to generate my RTF documents. In the reference manual, it says the future plans include colors. Do you have a timeline for that? I would like to put in a request for text color. Thank you!

Writing RTF document with auto-date formatting behaves unexpectedly in non-english system locales

Copying issue text from here

@NNaikp could you share your output on timestamp and R language setting? Thanks!

Github doesn't support .rtf so I have attached the file here (tlf-primary.docx) as .docx. Here is also a screenshot from the .rtf file:

image

My default language in Word is UK english.

When I did the review I set Sys.setenv(LANG = "en") as it was showing me error messages in danish. But after some googling I can see that the locale is still Danish, also if I set the language to English:

> Sys.setenv(LANG = "en")
> Sys.getlocale()
[1] "LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252"

After running Sys.setlocale(locale = "English") I see

> Sys.setlocale(locale = "English")
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"

Which yields:

image

Maybe pharmaRTF::write_rtf needs to check the locale before sinking the file? I can see from the documentation of Sys.setlocale() that it is OS dependent. The one above is Windows (my local). This one is from a linux server:

> Sys.getlocale()
[1] "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C"

Errors on huxtable 5.0.0

Hi guys,

I've been running reverse dependency checks on huxtable dependencies. pharmaRTF currently gets a couple of errors in running examples:

*   checking examples ... ERROR
  
    > library(huxtable)
    
 ...
    > ht <- huxtable(
    +   column1 = 1:5,
    +   column2 = letters[1:5]
    + )
    > rtf <- rtf_doc(ht, list(hf_line("aTitle")))
    > 
    > header_rows(rtf)
    Error in UseMethod("header_rows") : 
      no applicable method for 'header_rows' applied to an object of class "rtf_doc"
    Calls: header_rows
    Execution halted

I guess header_rows is a pharmaRTF method that is now getting interfered with by the new huxtable generic and function, of the same name.

I also get some testing failures:

      [ OK: 212 | SKIPPED: 0 | WARNINGS: 1 | FAILED: 5 ]
      1. Error: insert_buffer adds a blank column correctly (@test_helpers.r#37) 
      2. Failure: hf_string orderes lines properly (@test_rtf-code-generators.r#24) 
      3. Failure: header_string lines populates correctly (@test_rtf-code-generators.r#123) 
      4. Failure: header_string lines populates correctly (@test_rtf-code-generators.r#124) 
      5. Failure: rtf_doc returns a list with a table, title, and footnotes (@test_rtf_doc.r#14) 

You can test the latest version of huxtable with

remotes::install_github("hughjonesd/huxtable")

The master branch is now in bugfix-only mode.

Question about titles and footnotes in the body of the document

Hi Eli,

This is a really great package!
However, my company standards dictate that

outputs must not include any text in the header or footer, as they are reserved for regulatory publishing.

Is is possible to do this with pharmaRTF now? Or could it be sometime in the future?

Thanks!

About column name in RTF

Hi,

The pharmaRTF package is so good to creat RTF file, but I have a query that what's the reason put the column names in header. According to RTF in clinical trials, we usually put the whole table including column names in the RTF body part, certainly I'm not familiar with RTF.

I'm looking for some solutions to creat RTF instead of SAS in R

Thanks!

Question on using pharmaRTF in reporting

Is it possible to use this package to generate a word report which has proper table formatting as shown in this package but also with proper table numbering and referencing?

Update with tibble 3.1.0 breaks read_hf

Thanks to @DawnYe for this report in atorus-research/CDISC_pilot_replication#7.

With tibble 3.1.0 even my_tibble[FALSE, "notAColumn"] <- 1 will result in a new column being created. This is intended behavior for tibble now. This breaks fill_missing_data() which is an unexported function in read_hf.R. This is the offending line:

 .data[is.na(.data[var]), var] <- correct_defaults(var)

correct_defaults returns NULL when var is 'type'. This would never happen in an actual hf_file but even if it returns null, tibble is trying to add a new column and failing because its not a vector, a bare list, a data frame or a matrix.

Thankfully this is an easy fix. Either add type as a option in the correct_defaults as a blank matrix, or add an if statement like the following:

if(any(is.na(.data[[var]]))
          .data[is.na(.data[[var]]), var] <- correct_defaults(var)

Gap between column titles and table body in LibreOffice Writer

Hi,

Thanks for creating this. One thing that I have noticed is that the generated RTF files look different in LibreOffice Writer compared to how they look in Microsoft Word. In LibreOffice, there is an extra gap between the column heading and the table body that is not present in Word. While it looks as if things are being rendered differently, it this something that can be addressed?

Many thanks,

John

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.