ddotta / tablexlsx

R package to export data frames from R to xlsx workbook
https://ddotta.github.io/tablexlsx/
Other
16 stars 1 forks source link

Evolution api #28

Closed JulienBlasco closed 5 months ago

JulienBlasco commented 6 months ago

Slight changes to API in order to solve :

:warning: We need to change the documentation accordingly

The main changes are that mergecol can now be used with multiple data frames, and that we can only supply character arguments instead of lists in the following cases:

  1. There is only one data.frame
  2. The value of the argument is to be the same for all data frames (e.g. same footnote)
JulienBlasco commented 6 months ago

Example uses (taken from the example gallery):

Using character argument in footnote1:

df1 %>% toxlsx(path = mypath, footnote1="hello")

Using character argument in mergecol:

df2 %>% toxlsx(path = mypath, mergecol = c("country","group"))

Using length-one character argument for footnote3 (so the same footnote is added to each table)

list(tb1,tb2) %>%
  toxlsx(tosheet = list("tb1" = "mydata",
                        "tb2" = "mydata"),
         footnote1 = list("tb1" = "The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant.",
                          "tb2" = "The data give the speed of cars and the distances taken to stop. Note that the data were recorded in the 1920s."),
         footnote2 = list("tb1" = "Predicted attribute: class of iris plant.",
                          "tb2" = "Data recorded in the 1920s"),
         footnote3 = "Data is fictious.",
         mergecol = list(tb1 = "tables", tb2 = "tables"),
         path=mypath)
JulienBlasco commented 6 months ago

I mark this pull request as draft so we can change the documentation before merging.

JulienBlasco commented 6 months ago

Added another evolution : a bygroup argument (as suggested in #23 )

Example usage:

toxlsx(mtcars, path = tempdir(), bygroup = "cyl", groupname = TRUE)
JulienBlasco commented 5 months ago

@ddotta les modifications que j'ai proposées engendrent des incohérences dans la documentation et les tests. Je te laisse corriger si tu as le temps. Sinon je veux bien que tu m'expliques rapidement les points à mettre à jour. Merci 🙏

ddotta commented 5 months ago

Merci pour tout ton travail @JulienBlasco, j'essaye de dégager du temps en fin de semaine pour tout regarder ! 🚀