-
-
Notifications
You must be signed in to change notification settings - Fork 46
Vignettes #1545
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
base: teal_reportable
Are you sure you want to change the base?
Vignettes #1545
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "Adding Support for Reporting to Custom Modules" uses old solution with
reporter
arg in the $server - "getting started with teal" has very short subsections which links to longer documentations. Reporter here adds extra 100 lines which changes look of the vignette so much. IMO describing possible values of
init(reporter)
can be shorter just bullet-points instead of sections. Maybe we should change "Adding Support for Reporting to Custom Modules" to "Creating reproducible reports" (name tbd) and describe everything related to report there?
@gogonzo about
Do you think this should be a document in |
We can do this:
|
@gogonzo make sense! |
We for sure need |
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Ok, I:
Left 3 TODO in |
tcard <- c("Templated information", card) | ||
attributes(tcard) <- attributes(card) | ||
tcard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nasty. c
removes all classes and attributes. We can substitute this example to use edit_teal_card
.
So it's
custom_reporter_template$set_template(
function(card) {
edit_teal_card(card, append = "Templated information", after = 0)
}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use append(card, <something to add>, after = 0)
- then it doesn't loose a class because a first argument is a card
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think I'll go with this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gogonzo append
doesn't loose the class, but it looses metadata
attribute, so there is no name to be displayed in Reporter previewer.
> custom_card <- teal_card()
> metadata(custom_card, "title") <- "The title"
> custom_card
An object of class "teal_card"
Slot "metadata":
Slot "metadata":$title
[1] "The title"
> append(custom_card, "x")
[[1]]
[1] "x"
> append(custom_card, teal_card("x"))
[[1]]
[1] "x"
attr(,"class")
[1] "teal_card"
> metadata(append(custom_card, teal_card("x")))
list()
What do you think about exposing append.teal_card
method that also keeps attributes?
We can actually just change edit_teal_card
to append.teal_card
and remove the part used to modify
See below: | ||
|
||
```{r module_2} | ||
my_module_with_reporting <- function(label = "example teal module") { | ||
module( | ||
label = label, | ||
server = function(id, data, reporter) { | ||
server = function(id, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module returns unmodified data while output shows the selected dataset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gogonzo for pointing this out. I wanted to keep the example easy, so we just show that it is enough to return(data)
to turn reporting on.
We can extend this example module by adding
rdata <- reactive({
eval_code(
data(),
substitute(head(dataname), env = list(dataname = as.name(input$dataname))),
keep_output = TRUE
)
})
return(rdata)
or
rdata <- reactive({
req(input$dataname)
obj <- data()
teal_card(obj) <- c(teal_card(obj), "## Glimpse of the dataset", head(obj[[input$dataname]]))
obj
})
return(rdata)
depending on whether we would like to build the report with eval_code
or with teal_card
.
I think eval_code
is more appropriate here, even though we have substitute
usage in it (that I think is advanced for regular R users). We can also extend this example by explaining the keep_output = TRUE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However this very same code is added in the next section Add content to the report card
So maybe keep Modify the body of the server function
as it is, and extend Add content to the report card
to use eval_code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this vignette needs to have two examples. Previously adding reporter was more complicated now Reporter is supported by default as teal_report
is passed to the teal_module's server. Only thing which user has to do is return(<teal_report>)
. I'd just mention keep_output
and add one markdown-heading element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I can remove the whole first example and just use the last one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified adding-support-for-reporting.Rmd vignette 2cca04b
custom_reporter_template <- Reporter$new() | ||
custom_reporter_template$set_template( | ||
# Need to return named `teal_card` | ||
function(card) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show some practical information, like setting a Rmd template or adding some header/footer etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was rather thinking about setting some templated text for disclaimers, data sources, data privacy information, etc as an information added on top or at the bottom of the card. This sentence can also be added to this example.
The Rmd
template could be useful, if we create some text that can be interpreted as rmarkdown
. Maybe including a logo that is taken from the web?
tcard <- c("Templated information", card) | ||
attributes(tcard) <- attributes(card) | ||
tcard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use append(card, <something to add>, after = 0)
- then it doesn't loose a class because a first argument is a card
|
||
#### Module-Level Reporting Control | ||
|
||
While the `reporter` parameter controls reporting globally, you can also disable reporting for specific modules using `disable_report()`. This allows you to have fine-grained control over which modules support reporting: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both, after
and disable_report
can control module's report. After is more powerful and it doesn't restrict to the report only but to the whole teal_report/teal_data
object. We can showcase how to modify the report using after
While the `reporter` parameter controls reporting globally, you can also disable reporting for specific modules using `disable_report()`. This allows you to have fine-grained control over which modules support reporting: | |
While the `reporter` parameter controls reporting globally, you can also manage a report document for a specific module using `after()` `disable_report()`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gogonzo there is a section following this sentence that presents the usage of after
:
Using the
after Function to Customize Module Report Cards
Do you think it's enough? It shows that you can adjust the teal_card
of teal_report
, but we can apply join_keys
modifications as well, and also an eval_code
to show that the whole teal_data/teal_report
can be changed in any direction, not only the @teal_report
field.
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Dawid Kałędkowski <dawid.kaledkowski@gmail.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Extends teal vignettes with new reporting features in
teal
.