IDEMSInternational / R-Instat

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

Improve the Describe > One Variable > Frequencies and Rating dialogue for the new html and objects changes #8094

Open rdstern opened 1 year ago

rdstern commented 1 year ago

@Patowhiz, @derekagorhom (and @N-thony )

This started as a more general issue about all the One Variable and Two/Three variable summary dialogues. But then I found enough to consider and do on just these two dialogues. And a simple and useful starting point too

I suggest it is an excellent for Derrick to work on, after reflection by Patrick and then his guidance next week. Though it can start this week if you both have the time.

As data, you can try the One Variable > Frequencies with the usual survey data. For the rating data use the efc data from sjmisc in the library - variables c82cop1 to cop9.

  1. Compare the code for the current one variable frequencies, with Rating, and with the 2-variable frequencies that has already been updated.:
# Using the dialog: Frequencies

sjmisc::frq(x=data_book$get_columns_from_data(data_name="survey", col_names=c("village","field","size","fert","variety","yield","fertgrp"), force_as_data_frame=TRUE, remove_labels=TRUE, drop_unused_filter_levels=TRUE), out="txt")

Compare with the code for the rating dialogue:

# Using the dialog: Rating Data

columns <- data_book$get_columns_from_data(data_name="survey", col_names=c("fert","size"), use_current_filter=FALSE)
sjPlot::tab_stackfrq(items=columns, alternate.rows=TRUE, show.n=TRUE, show.total=TRUE, show.na=TRUE)
rm(columns)

and compare both of these with the 2-way frequencies that (I think?) Patrick has changed for the new system.

# Using the dialog: Two Way Frequencies

survey <- data_book$get_data_frame(data_name="survey", drop_unused_filter_levels=TRUE)
last_table <- sjPlot::sjtab(data=survey, village, variety, show.summary=FALSE, digits=0, fun="xtab", title="", string.total="Total")
data_book$add_object(data_name="survey", object_name="last_table", object_type_label="table", object_format="html", object=last_table)
data_book$get_object_data(data_name="survey", object_name="last_table", as_file=TRUE)
rm(list=c("last_table", "survey"))

And for reference the new code for skim from the summary dialogue.

# Using the dialog: One Variable Summarise

survey <- data_book$get_data_frame(data_name="survey")
last_summary <- skimr::skim_without_charts(data=survey, c("village","field","size","fert","variety","yield","fertgrp"))
data_book$add_object(data_name="survey", object_name="last_summary", object_type_label="summary", object_format="text", object=last_summary)
data_book$get_object_data(data_name="survey", object_name="last_summary", as_file=TRUE)
rm(list=c("last_summary", "survey"))

Now, most of our dialogues are like the 2-way frequencies, namely: a) Get the variables or the data frame b) Do something c) Sort out the results

The frequencies does everything together - that needs to be split. The rating does a) and b) sort of as I would like. It needs to change to add c).

So far, so good. Now my first question - and partly to Patrick.

The frequencies dialogue gives the option of text output or html? I notice that skim only outputs to text, and you produce a summary object. In contrast 2-way frequencies only produces html and produces a table object.

Do we want options for other dialogues, e.g. for skim to be able to produce html?

I note that text output can be maximised and then saved as txt, while html similarly is saved as html. Will there be more options for the maximised windows?

rdstern commented 1 year ago

@N-thony could you re-allocate this dialogue. Perhaps to Derrick?

  1. The One-way frequencies Table button could still usefully improve the code to have the a) b) c) parts I mention above. So separate a) and b)
  2. So could the graph option.
  3. The stem now doesn't give any results. That's because it is missing part c)!

(The rating data dialogue looks fine and shows what the commands should look like.)

I wonder who tested the changes to this dialogue, and allowed the new version to be merged?

N-thony commented 1 year ago

@derekagorhom any plan about what is remaining here?