DidierMurilloF / FielDHub

FielDHub is an R Shiny design of experiments (DOE) app that aids in the creation of traditional, unreplicated, augmented and partially replicated (p-rep) designs applied to agriculture, plant breeding, forestry, animal and biological sciences.
https://didiermurillof.github.io/FielDHub/
Other
39 stars 20 forks source link

fct_full_factorial - factor labels #6

Closed Prof-ThiagoOliveira closed 3 years ago

Prof-ThiagoOliveira commented 3 years ago

Hi, I created a new argument to keep the data frame's factors labels when data is provided. If TRUE keeps data labels; otherwise, FALSE, the original numeric labels are kept.

Please, review my changes and adapt them to your own convenience.

  1. Original output (factorLabels = FALSE):

    FACTORS <- rep(c("A", "B", "C"), c(2,3,2))
    LEVELS <- c("a0", "a1", "b0", "b1", "b2", "c0", "c1")
    data_factorial <- data.frame(list(FACTOR = FACTORS, LEVEL = LEVELS))
    print(data_factorial)
    # This in an RCBD arrangement with 5 reps in 3 locations.
    fullFact2 <- full_factorial(setfactors = NULL, reps = 5, l = 3, type = 2,
                            plotNumber = c(101,1001,2001),
                            continuous = FALSE,
                            planter = "serpentine",
                            seed = 326,
                            locationNames = c("Loc1","Loc2","Loc3"),
                            factorLabels = FALSE,
                            data = data_factorial)
    fullFact2$infoDesign
    head(fullFact2$fieldBook,10)
    ID LOCATION PLOT REP FACTOR_A FACTOR_B FACTOR_C TRT_COMB
    1   1     Loc1  101   1        1        4        7    1*4*7
    2   2     Loc1  102   1        2        5        6    2*5*6
    3   3     Loc1  103   1        2        4        6    2*4*6
    4   4     Loc1  104   1        1        3        7    1*3*7
    5   5     Loc1  105   1        2        3        6    2*3*6
    6   6     Loc1  106   1        2        5        7    2*5*7
    7   7     Loc1  107   1        2        4        7    2*4*7
    8   8     Loc1  108   1        1        3        6    1*3*6
    9   9     Loc1  109   1        1        5        7    1*5*7
    10 10     Loc1  110   1        1        5        6    1*5*6
  2. New output (factorLabels = TRUE):

    
    fullFact2 <- full_factorial(setfactors = NULL, reps = 5, l = 3, type = 2,
                            plotNumber = c(101,1001,2001),
                            continuous = FALSE,
                            planter = "serpentine",
                            seed = 326,
                            locationNames = c("Loc1","Loc2","Loc3"),
                            factorLabels = TRUE,
                            data = data_factorial)
    fullFact2$infoDesign
    head(fullFact2$fieldBook,10)

ID LOCATION PLOT REP FACTOR_A FACTOR_B FACTOR_C TRT_COMB 1 1 Loc1 101 1 a1 b0 c0 a1b0c0 2 2 Loc1 102 1 a1 b2 c0 a1b2c0 3 3 Loc1 103 1 a0 b2 c1 a0b2c1 4 4 Loc1 104 1 a0 b0 c1 a0b0c1 5 5 Loc1 105 1 a1 b1 c1 a1b1c1 6 6 Loc1 106 1 a1 b1 c0 a1b1c0 7 7 Loc1 107 1 a0 b0 c0 a0b0c0 8 8 Loc1 108 1 a1 b2 c1 a1b2c1 9 9 Loc1 109 1 a0 b2 c0 a0b2c0 10 10 Loc1 110 1 a1 b0 c1 a1b0c1



2. Latin Square
  - I included the functions class, summary and print
  - Note I have included the output infoDesign (I think it should be important to standardize all functions to return this argument).

3. Class - I suggest you include all classes as "fielDHub" - see Files Changed
Again, all I have done here are suggestions that I think are important to contribute to the package's output for the end-user.