Skip to content

Commit de3245f

Browse files
committed
support for n_permu > combo/permuteCount cases
1 parent 10f3d9a commit de3245f

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

R/auxiliary_funcs.R

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ get_arrangement <- function(
3939

4040
args <- list(v = v, m = m, repetition = replace)
4141

42+
n_possible <- do.call(paste0(which, "Count"), args)
43+
4244
if (!isFALSE(progress)) {
4345
progress <- interactive()
4446
}
4547
if (progress) {
46-
if (is.null(count <- n_sample)) {
47-
count <- do.call(paste0(which, "Count"), args)
48+
if (isTRUE((n_step <- n_possible) > n_sample)) {
49+
n_step <- n_sample
4850
}
4951
assign(
50-
"pb", ProgressBar$new(count),
52+
"pb", ProgressBar$new(n_step),
5153
envir = environment(func)
5254
)
5355
body(func) <- as.call(c(
@@ -59,12 +61,15 @@ get_arrangement <- function(
5961

6062
args <- c(args, list(FUN = func, FUN.VALUE = func_value))
6163

62-
if (is.null(n_sample)) {
63-
do.call(paste0(which, "General"), args)
64-
} else {
64+
if (isTRUE(n_sample < n_possible)) {
6565
args$n <- n_sample
6666
args$seed <- getOption("pmt_seed")
6767
do.call(paste0(which, "Sample"), args)
68+
} else {
69+
possible <- do.call(paste0(which, "General"), args)
70+
if (is.null(n_sample)) possible else {
71+
possible[sample.int(n_possible, n_sample, replace = TRUE)]
72+
}
6873
}
6974
}
7075

vignettes/examples.Rmd

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ t$p_value
211211
```{r}
212212
# See ?KolmogorovSmirnov or ?twosample.ks
213213
t <- pmt(
214-
"twosample.ks"
214+
"twosample.ks", n_permu <- 5000
215215
)
216216
217217
# See ?Table2.8.1
@@ -362,6 +362,9 @@ t$feed(Table4.1.1)
362362
363363
t$statistic
364364
t$p_value
365+
366+
t$n_permu <- 4000
367+
t$p_value
365368
```
366369

367370
## Example 4.1.1
@@ -401,6 +404,9 @@ t$feed(Table4.1.1)
401404
t$statistic
402405
t$p_value
403406
407+
t$n_permu <- 4000
408+
t$p_value
409+
404410
t$type <- "approx"
405411
t$p_value
406412
```
@@ -421,6 +427,9 @@ t$feed(data.frame(
421427
422428
t$statistic
423429
t$p_value
430+
431+
t$n_permu <- 4000
432+
t$p_value
424433
```
425434

426435
## Example 4.3.1

0 commit comments

Comments
 (0)