Skip to content

Commit

Permalink
use rep.int & rep_len
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Sep 11, 2023
1 parent 59edc7d commit 9113175
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/ANOVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ANOVA <- R6Class(
bar_.. <- mean(data)
bar_i. <- c(
lapply(
splited, function(x) rep.int(mean(x), length(x))
splited, function(x) rep_len(mean(x), length(x))
), recursive = TRUE, use.names = FALSE
)

Expand Down
4 changes: 2 additions & 2 deletions R/ContingencyTableTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ ContingencyTableTest <- R6Class(

private$.data_permu <- lapply(
X = permutations(
v = rep(seq_len(r), row_sum),
v = rep.int(seq_len(r), row_sum),
nsample = private$.n_permu, layout = "list"
),
FUN = function(data, col_index) {
vapply(
X = split(data, col_index), USE.NAMES = FALSE,
FUN = tabulate, nbins = r, FUN.VALUE = integer(r)
)
}, col_index = rep(seq_len(c), col_sum)
}, col_index = rep.int(seq_len(c), col_sum)
)
},

Expand Down
2 changes: 1 addition & 1 deletion R/KSampleTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ KSampleTest <- R6Class(

private$.raw_data <- setNames(
c(data, recursive = TRUE, use.names = FALSE),
rep(seq_along(data), times = vapply(data, length, integer(1)))
rep.int(seq_along(data), vapply(data, length, integer(1)))
)
},

Expand Down
2 changes: 1 addition & 1 deletion R/KolmogorovSmirnov.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ KolmogorovSmirnov <- R6Class(
m <- length(private$.data$x)
n <- length(private$.data$y)

tmp <- rep.int(1 / m, m + n)
tmp <- rep_len(1 / m, m + n)
private$.statistic_func <- function(x, y) {
max(abs(cumsum(`[<-`(tmp, order(c(x, y)) <= m, -1 / n))))
}
Expand Down
2 changes: 1 addition & 1 deletion R/TwoSamplePairedTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TwoSamplePairedTest <- R6Class(
.calculate_statistic = function() {
if (private$.use_swapped) {
private$.statistic <- private$.statistic_func(
swapped = rep.int(FALSE, nrow(private$.data))
swapped = rep_len(FALSE, nrow(private$.data))
)
} else {
super$.calculate_statistic()
Expand Down

0 comments on commit 9113175

Please sign in to comment.