Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Nov 22, 2023
1 parent ac18955 commit ec171e0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
8 changes: 3 additions & 5 deletions R/ANOVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ ANOVA <- R6Class(
k <- length(splited)

bar_.. <- mean(data)
bar_i. <- c(
lapply(
splited, function(x) rep_len(mean(x), length(x))
), recursive = TRUE, use.names = FALSE
)
bar_i. <- unlist(lapply(
splited, function(x) rep.int(mean(x), length(x))
), recursive = FALSE, use.names = FALSE)

mst <- sum((bar_i. - bar_..)^2) / (k - 1)
mse <- sum((data - bar_i.)^2) / (N - k)
Expand Down
4 changes: 3 additions & 1 deletion R/Correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Correlation <- R6Class(
order_x <- order(x)
x_reorder <- x[order_x]

i_index <- c(lapply(seq_len(n - 1), seq_len), recursive = TRUE)
i_index <- unlist(lapply(
seq_len(n - 1), seq_len
), recursive = FALSE, use.names = FALSE)
j_index <- rep.int(seq_len(n)[-1], seq_len(n - 1))
x_equal <- (x_reorder[i_index] == x_reorder[j_index])

Expand Down
8 changes: 5 additions & 3 deletions R/JonckheereTerpstra.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ JonckheereTerpstra <- R6Class(
.define = function() {
k <- as.integer(get_last(names(private$.data)))
ij <- list(
i = c(lapply(seq_len(k - 1), seq_len), recursive = TRUE),
i = unlist(lapply(
seq_len(k - 1), seq_len
), recursive = FALSE, use.names = FALSE),
j = rep.int(seq_len(k)[-1], seq_len(k - 1))
)
private$.statistic_func <- function(data, group) {
where <- split(seq_along(group), group)
sum(c(.mapply(
sum(unlist(.mapply(
FUN = function(i, j) {
outer(data[where[[i]]], data[where[[j]]], "<")
}, dots = ij, MoreArgs = NULL
), recursive = TRUE))
), recursive = FALSE, use.names = FALSE))
}
},

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

private$.raw_data <- setNames(
c(data, recursive = TRUE, use.names = FALSE),
unlist(data, recursive = FALSE, use.names = FALSE),
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_len(1 / m, m + n)
tmp <- rep.int(1 / m, m + n)
private$.statistic_func <- function(x, y) {
max(abs(cumsum(`[<-`(tmp, order(c(x, y)) <= m, -1 / n))))
}
Expand Down
4 changes: 3 additions & 1 deletion R/MultipleComparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ MultipleComparison <- R6Class(
k <- as.integer(get_last(names(private$.raw_data)))
private$.ij <- list(
i = rep.int(seq_len(k - 1), seq.int(k - 1, 1)),
j = c(lapply(seq.int(2, k), seq.int, to = k), recursive = TRUE)
j = unlist(lapply(
seq.int(2, k), seq.int, to = k
), recursive = FALSE, use.names = FALSE)
)
},

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

.calculate_statistic = function() {
private$.statistic <- private$.statistic_func(
swapped = rep_len(FALSE, nrow(private$.data))
swapped = rep.int(FALSE, nrow(private$.data))
)
},

Expand Down

0 comments on commit ec171e0

Please sign in to comment.