IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

Summary tables has some new problems? #8006

Open rdstern opened 1 year ago

rdstern commented 1 year ago

@Patowhiz and maybe @lilyclements this is a dialogue that was in html, so I think perhaps some part of it may have been missed in the recent adaptations. It now doesn't seem to give summary statistics - though it does give counts.
Here for the Dodoma data, getting summaries by month for tmax and tmin:

image

Gives: image

The R code currently generated is as follows:

# Code generated by the dialog, Frequency/Summary Tables

summary_table <- data_book$summary_table(data_name="dodoma", columns_to_summarise=c("tmax","tmin"), factors="month_abbr", treat_columns_as_factor=FALSE, j=1, summaries=c("summary_mean", "summary_min", "summary_max", "p25", "p75", "summary_median", "summary_count_non_missing", "summary_n_distinct"))

summary_table <- data_book$summary_table(data_name="dodoma", columns_to_summarise=c("tmax","tmin"), factors="month_abbr", treat_columns_as_factor=FALSE, j=1, summaries=c("summary_mean", "summary_min", "summary_max", "p25", "p75", "summary_median", "summary_count_non_missing", "summary_n_distinct"))
last_table <- (mmtable2::mmtable(data=summary_table, cells=value) + mmtable2::header_left_top(variable='summary-variable') + mmtable2::header_top_left(variable=month_abbr))
data_book$add_object(data_name="dodoma", object_name="last_table", object_type_label="table", object_format="html", object=last_table)
data_book$get_object(data_name="dodoma", object_name="last_table")
rm(list=c("last_table", "summary_table"))

I don't know why the main line is given twice. But I guess that does no harm? I get the same result when I comment out one occurrence of it.

Patowhiz commented 1 year ago

@rdstern the extra first line is due to how the dialog was originally implemented. It doesn't have any output effect but I have now fixed that in PR #8008 .

@rdstern @lilyclements I suspect the blanks is probably due to the summary R function when it comes to dealing with missing values. I checked the "Omit Missing Values" option and the blanks were replaced with values. Version 0.7.6 also behaves the same. @rdstern is there a version that didn't have this issue?

@lilyclements do you agree with my opinion, would you like to check on the R function or should I? You seem to have worked on the function in PR #7925.

@rdstern what is the intention of the Store output checkbox option?

Dialog

dialog

Output

output
lilyclements commented 1 year ago

@Patowhiz that is a good point, and is what is happening here. Thanks for working that out!

@rdstern are you happy for this dialog to remain like this? Perhaps I could add in "NA"'s more explicitly to make it clearer