patriciamar/ShinyItemAnalysis

Report template

Closed this issue · 8 comments

Report template may be changable.

Preferably offer editing of RMarkdown file - offer the user to include more comments etc.

@LStepanek and @JakHou : Do you have any idea how to do that?

I think that logic of the customizable report could follow these steps:

(i) Placement of an HTML textarea at the report tab (or a new tab?) of the application and initialization of its default value to the current version of Rmarkdown template.
(ii) HTML textarea is an input type of object -- a user can add or delete lines of text on her/his own choice.
(iii) After saving a modified but still working (let's suppose this feature would be probably used only by experienced users) template into a new server file (let's say *_modified.Rmd), the new file could be used as an input for immediate report generating. The template file *_modified.Rmd should be empty and attached on server from the very beginning -- a user would just populate it by mix of original lines coming from default template and her/his modifications made via HTML textarea. Each new session of the app should delete a content of the *_modified.Rmd file (it can be done by simple hidden R procedure added to the server.R file (similar to counter procedure)).

Maybe I am wrong but guess this could do the job. I have some previous experience with HTML textarea in Shiny, and can immerse myself into this during the forthcoming weekend.

I wonder if there is a tool/R package/a way enabling something like a spell-and-syntax check of .Rmd files -- it would prevent a generating of the report based on a not working, user-modified .Rmd template (and resulting necessarily in an error).

This sounds reasonable. Any contribution will be welcomed!
I would solve bad syntax with warning/error and replacing customized template with default one (not sure if it is easy solution or not). I think that first we have to try to use bad syntax and we'll see if the app can handle it or not..

For now, I would prefer including a textarea in certain places, but not allowing user to modify the whole document. It would be great, if the area that was edited by the user may be somehow highlighted (in light grey) to make it apparent what was modified by user.
Following places may serve as first try:

  • Intro page: Title (include title of your test below the main title)
  • (advanced): Item wording (leave space for item wording or even include item wording before each item graph)

In the new version (1.2.3), author and Title may be edited on Title page of the report.

What remains to solve is upload and inclusion of item wording, or offering some space for item wording (e.g. by printing each item on separate page and keeping upper half of the page empty for subsequent printing).

Well, I was thinking about this one more time and there is some solution. Run code below with an example how could the report page look like. The text areas are visible only when customize settings is selected. By default it contains the text from reports. This text can be replaced by user's own text.

It won't be difficult to create this "web form" for report page but it will take me some time to connect all parts with html and pdf report. Let me know what do you think!

library(shiny)

if (interactive()) {
  
  ui <- fluidPage(
    h3("Settings of report"),
    p(code("ShinyItemAnalysis"), " offers an option to download a report in HTML or PDF format. PDF report
                           creation requires latest version of", a("MiKTeX", href = "https://miktex.org/howto/install-miktex",
                                                                   target = "_blank"),
      "(or other TeX distribution). If you don't have the latest installation, please, use the HTML report."),
    p("There is an option whether to use customize settings. By checking the", strong("Customize settings"),
      "local settings will be offered and use for each selected section of report. Otherwise the settings
                           will be taken from pages of application. You can also include your name into report as well as the name
                           of dataset which was used. "),
    fluidRow(
      column(2, radioButtons("report_format", "Format of report", c("HTML" = "html", "PDF" = "pdf"))),
      column(2, checkboxInput("customizeCheck", "Customize settings", FALSE))
    ),
    h3("Content of report"),
    h4("Header"),
    fluidRow(
      column(2, textInput("reportAuthor", "Author")),
      column(2, textInput("reportDataName", "Dataset"))
    ),
    h4("Summary"),
    h5("Total scores"),
    checkboxInput("id1", label = "Summary table of total scores", value = T),
    conditionalPanel(condition = "input.customizeCheck",
                     textAreaInput("text1", "Text area",
                  "For selected cut-score, blue part of histogram shows students with total score above the cut-score, 
grey column shows students with total score equal to the cut-score and red part of histogram shows students below the cut-score.",
                  width = "800px", height = "75px")),
    checkboxInput("id2", label = "Histogram of total scores", value = T),
    h4("Scoring"),
    conditionalPanel(condition = "input.customizeCheck",
                     textAreaInput("text2", "Text area", 
                  "Total score also known as raw score is a total number of correct answers. It can be used to compare individual 
score to a norm group, e.g. if the mean is 12, then individual score can be compared to see if it is below or 
above this average. Percentile indicates the value below which a percentage of observations falls, e.g. 
a individual score at the 80th percentile means that the individual score is the same or higher than the scores 
of 80% of all respondents. Success rate is the percentage of success, e.g. if the maximum points of test is 
equal to 20 and individual score is 12 then success rate is 12/20 = 0.6, i.e. 60%. Z-score or also standardized 
score is a linear transformation of total score with a mean of 0 and with variance of 1. If X is total score, 
M its mean and SD its standard deviation then Z-score = (X - M) / SD. T-score is transformed Z-score with a 
mean of 50 and standard deviation of 10. If Z is Z-score then T-score = (Z * 10) + 50.",
                  width = "800px", height = "200px")),
    checkboxInput("id3", label = "Summary table of standard scores", value = T),
    h4("Validity"),
    h5("Correlation structure"),
    conditionalPanel(condition = "input.customizeCheck",
                     textAreaInput("text3", "Text area", 
                  "Polychoric correlation heat map is a correlation plot which displays a polychoric correlations of items. 
The size and shade of circles indicate how much the items are correlated (larger and darker circle means larger correlation). 
The color of circles indicates in which way the items are correlated - blue color shows possitive correlation 
and red color shows negative correlation.",
                  width = "800px", height = "100px")),
    checkboxInput("id4", label = "Correlation heatmap", value = F),
    conditionalPanel(condition = "input.customizeCheck",
                     conditionalPanel(condition = "input.id4",
                                      div(style = "display: inline-block; vertical-align: middle; width: 40%;",
                                          numericInput('corr_plot_clust_report',
                                                       label = 'Number of clusters',
                                                       value = 1,
                                                       min = 1,
                                                       max = 1)))),
    conditionalPanel(condition = "input.customizeCheck",
                     textAreaInput("text4", "Text area",
                  "Scree plot displays the eigenvalues associated with an component or a factor in descending order versus the 
number of the component or factor.",
                  width = "800px", height = "55px")),
    checkboxInput("id5", label = "Scree plot", value = F)
  )
  
  
  server <- function(input, output) {
  }
  
  shinyApp(ui, server)
}

This is actually what @LStepanek suggested some time before but I would not let the user to download tex file. Main reason - it won't work outside the shiny app.

This looks nice. Sections which were edited should be somehow highlighted (grey shading?).
Is it possible to implement this approach also to add item wording below plot of each item?