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

Adding functions keyboard to calculator #8968

Closed Fidel365 closed 1 month ago

Fidel365 commented 2 months ago

Fixes partially issue #8905 @rdstern this is ready for review execept for the following comments;1.We don't have coeffs2 key working yet, and 2.I am missing tooltips for the first set row of keys

rdstern commented 2 months ago

@Fidel365 what an excellent start.
a) The functions keyboard, in the drop-down, should not be the second one. It should be last in the list.
b) Tooltip for ave: Gives the mean, as a column. For example ave(c(1,2,3,4,10)) = 4, 4, 4, 4, 4. c) Tooltip for ave_fun: As ave key, but change mean (in the function) to any summary, e.g. sd, for std dev or raster::cv for coefficient of variation. d) ave_fac: In the function add a space after the comma to make it clearer. Tooltip: Gives the means for one or more factors. e) ave_both: Add a space before the first comma and another space before the second. Tooltip: Gives any summary measure for one or more factors. f) coeffs: You have repeated the ave function. Instead use coeffs: polynom::poly.calc( ) , with arguments (x= ). g) prod, combn, coef keys - also still ave function! See the 4th row of keys in the issue. h) coeffs2 : That was a long way further down in the issue. I wondered if you would look? It is: as.numeric(purrr::map(.x=(nrow(data_RDS)-1):0, .f = ~sum(combn(rootsx3[1:nrow(data_RDS)-1], .x , FUN=prod)))) Note here the data_RDS, which needs to give the name of the current data frame. (That's in a lot of the other keys, e.g. prob keyboard, random sample keys.) i) dsum is again currently your favourite ave code. See the issue row 5. Also rename the key as digitsum j) Swap the order of the fractions and decimals keys, see beow, as they go onto a new row. k) Tooltip for Pascal Gives Pascal triangles, e.g. for c(1,2,3,4) gives 1, (1,1), (1, 2, 1), (1, 3, 3, 1) l) The dssq code is missing a quote. It should have split="" m) Change dssq to digitssq and also digitssq* on the partner key. n) There is a new row 5 now with the four keys digitsum, digitsum*, pascal, pascal* Here: digitsum: digitsum( ) and with parameters digitsum(x= ) tooltip: Gives the sum of the digits, if the library calculator code has been run in the current session. pascal pascal( ) and with parameters pascal(x= ) tooltip Gives binomial coefficients, if the library calculator code has been run in the current session.

o) Then a new row 6 with digitsqu, digitsqu*, digitssq, digitssq* @Fidel365 here digitssqis the current dssq key, see point m) above and digitssq is the current dssq key. The other 2 keys are new. digitsqu: sapply( ,function(n){a<-as.integer(c(strsplit(as.character(n),split="")[[1]])); a^2}) no change with parameters. Tooltip: Squares of digits in an integer variable.
digitsqu* digitsqu( ) and add x= if parameters. Tooltip Squares of digits if the library calculator code has been run in the current session.

p) Row 7 now becomes fractions, fractions*, decimals, decimals* fractions and decimals just move down fractions is fractions( ) and add x= if parameters. Tooltip: Changes decimal data into fractions, if the library calculator code has been run in the current session. .
decimals
is decimals( ) and add x= is parameters. Tooltip: Changes fractions back to decimals if the library calculator code has been run in the current session. q) I am adding the script for the 8 functions with a * in the keyboard.
calculator_functions.zip

This needs to be added to the R-Instat library, and then I hope it will be easy to import and run. This may need @N-thony to advise on how this should be done and where it should go? I am hopeful this can go in the forthcoming update?

By the way I have been testing with the survey data. Not ideal for some of the functions, but useful for most.

Fidel365 commented 1 month ago

Still more work to come tomorrow morning.

Fidel365 commented 1 month ago

@rdstern I have made the changes requested here and this is ready for review

N-thony commented 1 month ago

c) Row 6 we produce polynomial objects. We have a "rule" in the R-Instat data sheet, that objects with an odd class have an (S) for structure, after the name. This may need some input from @N-thony? Here is a picture to show the situation: @Fidel365 have a look of this below for c) image

Fidel365 commented 1 month ago

@rdstern this is ready for rereview.

Fidel365 commented 1 month ago

@rdstern and now ready again.