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 presentation of the results for the crop dialogue #7659

Open rdstern opened 2 years ago

rdstern commented 2 years ago

In the current crops dialogue, the table of results needs to be copied and pasted into Excel. Then edited to present the results better and with fractions. This is for PICSA. a) In the output window it is now harder to copy part of the output from a command. (It is easy to copy a whole output.) b) But we could eventually produce a table with the required results in exactly the format we need. c) This uses our new tabulation system, where the gt package is used for formatting. This includes fmt_fraction, which is what we use in Excel to express the results as 2/10, rather than 0.18 (say). d) We also use proper dates in the year for the formatting, and do this by hand currently in Excel. Perhaps this could also be automatic?

This is not urgent, compared to other improvements, but is needed.

This will need @lilyclements to start off, because it uses the same gt package, as used in our general tabulation.

rdstern commented 1 month ago

@Fidel365 I assume you are ideal for this job? I could not find our climatic crops discussion on this topic any more, so I am now suggesting an addition to the Functions keyboard in the calculator. I saw the fmt_fraction in the gt package, which is the equivalent of what we currently do in Excel to present the crops information in a simple way. But just adding a column with the fraction into a data frame will be simple, and general, and consistent with R-Instat.

Here is the issue in stack-overflow and this is the function given there:

frac_den <- function(x, den) {paste0(round(x * den), "/", den)}

So we could also have

frac10 <- function(x)  {paste0(round(x * 10), "/", 10)}
frac20 <- function(x)  {paste0(round(x * 20), "/", 20)}
frac100 <- function(x)  {paste0(round(x * 100), "/", 100)}

Here is the current functions keyboard.
image

Please could you add a row of keys below the fractions row. The 4 keys are called frac10, frac20, frac100, frac_den. Then frac10 would givefrac10( ) frac20 gives frac20( ) frac100 gives frac100( ) frac_den( gives frac_den( , ). If Show parameters is ticked then this become frac_den(x= , denominator= ), with the cursor after the x=. The others just become frac10(x= ), etc.

The tooltips are for frac10: Give fraction our of 10 for a decimal value. For example for 0.36 the value is 4/10 frac20: Give fraction our of 20 for a decimal value. For example for 0.36 the value is 7/20 frac100: Give fraction our of 100 for a decimal value. For example for 0.36 the value is 36/100 frac_den: Give fraction for a given denominator. For example for frac_den(0.36, 50) gives 18/50.

@lilyclements I am wanting this generally, but also to add a fractions column once we have run the Climatic > PICSA > Crops dialog! With our R-Instat sort of users, I think there is a nice general teaching point here, becayse presenting results just as proportions or percentages is not simple for all. Could you include these really simple functions so they are also in the R-Instat extras (Or whatever it is called?) package? If so, I assume the R-Instat packages are automatically loaded, so we can give the commands like that?

@lilyclements I was earlier wondering about adding this option into the new Climatic > PICSA > Crops dialog. I am now happier to leave the improvements there, as they are. Once we have practiced with the gt presentation tables stuff, I suggest we might have a presentation crops dialog. It could add this column and then present the table just right to be in Word, etc.