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

agricolae package and giving commands to R-Instat #4438

Open rdstern opened 6 years ago

rdstern commented 6 years ago

There are various task views in R. One is called Experimental design - which is also for the analysis of experimental data. This says that the default package is agricolae. It has quite a lot in it, though it is pretty traditional stuff.

I was looking particularly for more significance tests and it has plenty. So that might be reason enough to include it - and add an agriccolae keyboard to our significance testing dialogue. Having access to these resources ,might also be a "quick win" in relation to the new Oxford funding. That will concentrate on newer ideas in agricultural research. But (if without too much effort, then it might be easy to show in relation to what is more conventional.

I also wondered how easily I could use some of the functions in agricolae anyway. So:

1) I added the package and dependencies through RStudio. Then started R-Instat again.
2) Then I tried one of the examples in the package. Here is the code in the agricolae guide:

library(agricolae) block<-c(rep("I",7),rep("II",6),rep("III",7)) trt<-c("A","B","C","D","g","k","l","A","B","C","D","e","i","A","B","C","D","f","h","j") yield<-c(83,77,78,78,70,75,74,79,81,81,91,79,78,92,79,87,81,89,96,82) out<- DAU.test(block,trt,yield,method="lsd", group=TRUE) print(out$groups) plot(out)

This gave rise to the following questions: a) The first command was library(agricolae). I am adding quite a few packages. Could we do this in R-Instat itself? b) Then I checked that the next 3 lines input data. This would only work if I had a data frame. So I made a new data frame with 20 observations.
c) Now I used Prepare > Column: Calculate > Calculations 3 times. I could equally have used Prepare > Column: Generate > Enter. d) I just used the rhs and then made the name the same as in the example above. Could this step with the 3 R commands be made quicker/simpler? For example could this become an option in the File > New?
e) Then I used agricolae::DAU.test(block,trt,yield,method="lsd", group=TRUE). Initially I used it in the calculator - as above. It seemed to run, (i.e. no error) but gave nothing in the output window. f) So I tried in the new Model > Hypothesis tests and gave it the name out, as in the code above. It ran and gave lots and lots of output. g) I checked with Prepare > R Object > View and the out object was available. Once more of that dialogue is enabled I assume we will be able to see more of the object.

This is exciting to me, both in the results we are getting already and in the translation of R commands in R-Instat. I would like to understand details a bit more and also see if there is any further we might/should go.

rdstern commented 6 years ago

In discussions with David I am now a bit further on this example:

1) Loading new packages. I enquired whether this had to be done through RStudio and could not become a facility in R-Instat. David's view is that RStudio does this really well (including dependencies) and from the internet. This is best left to RStudio. 2) Input of the 3 commands, with data could be done very nicely as part of the File > New dialogue as mentioned in #4439. 3) If additional lines like those need to be added, then this could use the Calculations dialogue. But more obvious is the Prepare > Column: Generate > Enter dialogue. 4) The Model > Hypothesis Tests dialogue is the right place for the command. In that instance the command: out<- DAU.test(block,trt,yield,method="lsd", group=TRUE) is given with the out as the name of the saved object. It then produces the default output as though the command was given without the assignment to out. And then it also saves it in this object.
5) As an option we might want to suggest no output when the result is saved in this dialogue. 6) Then it would be really good if the Prepare R Objects > View were implemented again.

Separately from this it does look worth having the agricolae package within R-Instat and to have the command in this package as a second keyboard in the hypothesis testing dialogue.

rdstern commented 6 years ago

I have changed the milestone back to 5.1. The agricolae package is now a keyboard and so this issue is sort of finished. But this example fits well with the questions being asked in #4445. So I am leaving it open for now. The facility of having agricolae commands available may even be an additional small output for Danny's Oxford work?