Hi, and welcome!
I'm going try to sneak up on this by starting out with something that appears to work, and illustrates that k
, which is not an argument in the FrF2
signature, doesn't do anything
suppressPackageStartupMessages(library(FrF2))
gen3 <- FrF2(k = 7, nruns = 16, generators = 3, randomize = FALSE)
no_k <- FrF2(nruns = 16, generators = 3, randomize = FALSE)
gen3 == no_k
#> A B C D E
#> 1 TRUE TRUE TRUE TRUE TRUE
#> 2 TRUE TRUE TRUE TRUE TRUE
#> 3 TRUE TRUE TRUE TRUE TRUE
#> 4 TRUE TRUE TRUE TRUE TRUE
#> 5 TRUE TRUE TRUE TRUE TRUE
#> 6 TRUE TRUE TRUE TRUE TRUE
#> 7 TRUE TRUE TRUE TRUE TRUE
#> 8 TRUE TRUE TRUE TRUE TRUE
#> 9 TRUE TRUE TRUE TRUE TRUE
#> 10 TRUE TRUE TRUE TRUE TRUE
#> 11 TRUE TRUE TRUE TRUE TRUE
#> 12 TRUE TRUE TRUE TRUE TRUE
#> 13 TRUE TRUE TRUE TRUE TRUE
#> 14 TRUE TRUE TRUE TRUE TRUE
#> 15 TRUE TRUE TRUE TRUE TRUE
#> 16 TRUE TRUE TRUE TRUE TRUE
Created on 2019-11-28 by the reprex package (v0.3.0)
Looking at gen3
, we can see quite a bit
# omitted duplicate reprex output from first example,
str(gen3)
#> Classes 'design' and 'data.frame': 16 obs. of 5 variables:
#> $ A: Factor w/ 2 levels "-1","1": 1 2 1 2 1 2 1 2 1 2 ...
#> ..- attr(*, "contrasts")= num [1:2, 1] -1 1
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : chr "-1" "1"
#> .. .. ..$ : NULL
#> $ B: Factor w/ 2 levels "-1","1": 1 1 2 2 1 1 2 2 1 1 ...
#> ..- attr(*, "contrasts")= num [1:2, 1] -1 1
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : chr "-1" "1"
#> .. .. ..$ : NULL
#> $ C: Factor w/ 2 levels "-1","1": 1 1 1 1 2 2 2 2 1 1 ...
#> ..- attr(*, "contrasts")= num [1:2, 1] -1 1
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : chr "-1" "1"
#> .. .. ..$ : NULL
#> $ D: Factor w/ 2 levels "-1","1": 1 1 1 1 1 1 1 1 2 2 ...
#> ..- attr(*, "contrasts")= num [1:2, 1] -1 1
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : chr "-1" "1"
#> .. .. ..$ : NULL
#> $ E: Factor w/ 2 levels "-1","1": 2 1 1 2 2 1 1 2 2 1 ...
#> ..- attr(*, "contrasts")= num [1:2, 1] -1 1
#> .. ..- attr(*, "dimnames")=List of 2
#> .. .. ..$ : chr "-1" "1"
#> .. .. ..$ : NULL
#> - attr(*, "desnum")= num [1:16, 1:5] -1 1 -1 1 -1 1 -1 1 -1 1 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : chr "1" "2" "3" "4" ...
#> .. ..$ : chr "A" "B" "C" "D" ...
#> - attr(*, "run.order")='data.frame': 16 obs. of 3 variables:
#> ..$ run.no.in.std.order: Factor w/ 16 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ run.no : int 1 2 3 4 5 6 7 8 9 10 ...
#> ..$ run.no.std.rp : Factor w/ 16 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
#> - attr(*, "design.info")=List of 12
#> ..$ type : chr "FrF2.generators"
#> ..$ nruns : num 16
#> ..$ nfactors : num 5
#> ..$ factor.names:List of 5
#> .. ..$ A: num -1 1
#> .. ..$ B: num -1 1
#> .. ..$ C: num -1 1
#> .. ..$ D: num -1 1
#> .. ..$ E: num -1 1
#> ..$ generators : chr "E=AB"
#> ..$ aliased :List of 3
#> .. ..$ legend: chr "A=A" "B=B" "C=C" "D=D" ...
#> .. ..$ main : chr "A=BE" "B=AE" "E=AB"
#> .. ..$ fi2 : chr
#> ..$ FrF2.version: chr "2.1"
#> ..$ replications: num 1
#> ..$ repeat.only : logi FALSE
#> ..$ randomize : logi FALSE
#> ..$ seed : NULL
#> ..$ creator : language FrF2(k = 7, nruns = 16, generators = 3, randomize = FALSE)
Created on 2019-11-28 by the reprex package (v0.3.0)
In particular the generator is identified.
attr(gen3, "design.info")$generators
[1] "E=AB"
But E=AB
doesn't work as an argument
FrF2(k = 7, nruns = 16, generators = "E = AB", randomize = FALSE)
Error in gen.check(k, generators) :
All generators must contain integer numbers from 1 to 4
or letters from A to D only.
<error/rlang_error>
All generators must contain integer numbers from 1 to 4
or letters from A to D only.
Backtrace:
█
1. └─FrF2::FrF2(k = 7, nruns = 16, generators = "E = AB", randomize = FALSE)
2. └─FrF2:::gen.check(k, generators)
>
I didn't find a way to specify the generators argument using any of "A", "B", "C", or "D".
And, of [1:4], only 4 works as an argument. Any of [1:3] produce
> FrF2(k = 7, nruns = 16, generators = 1, randomize = FALSE)
Error in gen.check(k, generators) :
This design is of resolution II and is not permitted in package FrF2.
<error/rlang_error>
This design is of resolution II and is not permitted in package FrF2.
Backtrace:
█
1. └─FrF2::FrF2(k = 7, nruns = 16, generators = 1, randomize = FALSE)
2. └─FrF2:::gen.check(k, generators)
Providing res
as an argument returns the error you reported for, seemingly any integer. The FrF2
signature has no res
and doesn't use ...
Looking at body(FrF2)
, there's no error message regarding multiple formal arguments. Moving res
around produces the message, indicating that nothing positional in the formal argument is required.
So, the only arguments to FrF2
that I was able to use to produce an object of class design
had to omit res
and provide 3
as the sole argument to generators.
Why this should be is unclear.