-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: use qtab() for crosstab() #117
Labels
enhancement
New feature or request
Comments
Oh, that's super cool! Thanks for pointing me to it. I will move to |
Yes, it indeed gives good speed up: library(microbenchmark)
N <- 100000
a <- sample(1:20, N, replace = TRUE)
b <- sample(1:300, N, replace = TRUE)
y <- matrix(rnorm(N), N, 1)
data <- y
var1 <- data.frame(a = a)
var2 <- data.frame(b = b)
microbenchmark(
ct1 <- fwildclusterboot:::crosstab(data = data, var1 = var1, var2 = var2),
ct4 <- fwildclusterboot:::crosstab4(data = data, var1 = var1, var2 = var2),
ct5 <- fwildclusterboot:::crosstab_qtab(data = data, var1 = var1, var2 = var2),
times = 1
)
# min lq mean median uq max
# 5.353802 5.353802 5.353802 5.353802 5.353802
# 225.850701 225.850701 225.850701 225.850701 225.850701
# 3.371901 3.371901 3.371901 3.371901 3.371901 Nice! :) |
s3alfisc
added a commit
that referenced
this issue
Jun 17, 2023
Merged
s3alfisc
added a commit
that referenced
this issue
Jun 18, 2023
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
qtab()
introduced in collapse 1.8.0 should be more efficient than the workaround with fsum(). You need to pass the data to the weights argumentw
ofqtab()
. In any case, even if that should not be the case,fsum()
now has an argumentfill = TRUE
, which you can set to avoid theres[is.na(res)] <- 0
line.The text was updated successfully, but these errors were encountered: