Skip to content

Migrate plyr::llply to lapply() #136

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ ci_auc_bootstrap <- function(roc, conf.level, boot.n, boot.stratified, progress,
progress <- roc_utils_get_progress_bar(progress, title="AUC confidence interval", label="Bootstrap in progress...", ...)

if (boot.stratified) {
aucs <- unlist(llply(1:boot.n, .fun=stratified.ci.auc, roc=roc, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), stratified.ci.auc, roc=roc))
}
else {
aucs <- unlist(llply(1:boot.n, .fun=nonstratified.ci.auc, roc=roc, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), nonstratified.ci.auc, roc=roc))
}

if (sum(is.na(aucs)) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions R/ci.auc.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ ci.auc.smooth.roc <- function(smooth.roc,
progress <- roc_utils_get_progress_bar(progress, title="AUC confidence interval", label="Bootstrap in progress...", ...)

if (boot.stratified) {
aucs <- unlist(llply(1:boot.n, stratified.ci.smooth.auc, roc=roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), stratified.ci.smooth.auc, roc=roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call))
}
else {
aucs <- unlist(llply(1:boot.n, nonstratified.ci.smooth.auc, roc=roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), nonstratified.ci.smooth.auc, roc=roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call))
}

if (sum(is.na(aucs)) > 0) {
Expand Down
8 changes: 4 additions & 4 deletions R/var.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@
auc.call <- as.call(c(utils::getS3method("auc", "smooth.roc"), auc.args))

if (boot.stratified) {
aucs <- unlist(llply(1:boot.n, stratified.ci.smooth.auc, roc=non.smoothed.roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), stratified.ci.smooth.auc, roc=non.smoothed.roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call))
}
else {
aucs <- unlist(llply(1:boot.n, nonstratified.ci.smooth.auc, roc=non.smoothed.roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), nonstratified.ci.smooth.auc, roc=non.smoothed.roc, smooth.roc.call=smooth.roc.call, auc.call=auc.call))

Check warning on line 138 in R/var.R

View check run for this annotation

Codecov / codecov/patch

R/var.R#L138

Added line #L138 was not covered by tests
}
}
## Non smoothed ROC curves variance
else {
if (boot.stratified) {
aucs <- unlist(llply(1:boot.n, stratified.ci.auc, roc=roc, .progress=progress, .parallel=parallel)) # ci.auc: returns aucs just as we need for var, so re-use it!
aucs <- unlist(lapply(seq_len(boot.n), stratified.ci.auc, roc=roc)) # ci.auc: returns aucs just as we need for var, so re-use it!
}
else {
aucs <- unlist(llply(1:boot.n, nonstratified.ci.auc, roc=roc, .progress=progress, .parallel=parallel))
aucs <- unlist(lapply(seq_len(boot.n), nonstratified.ci.auc, roc=roc))
}
}

Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-progress.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ test_that("can get bar works", {
expect_equal(names(my_progress), c("init", "step", "term"))
})

test_that("progress = text works", {
expect_output(var(r.wfns, method="bootstrap", boot.n=2, progress="text"))
})

test_that("progress = none works", {
expect_silent(var(r.wfns, method="bootstrap", boot.n=2, progress="none"))
})