Skip to content

Commit

Permalink
Renamed word.list to word_list
Browse files Browse the repository at this point in the history
  • Loading branch information
ngreifer committed Jul 7, 2019
1 parent 154fb93 commit c742bdb
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
20 changes: 10 additions & 10 deletions R/bal.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bal.plot <- function(obj, var.name, ..., which, which.sub = NULL, cluster = NULL
}
if (is.numeric(which.sub) && any(which.sub %in% levels(X$subclass))) {
if (any(!which.sub %in% levels(X$subclass))) {
w.l <- word.list(which.sub[!which.sub %in% levels(X$subclass)])
w.l <- word_list(which.sub[!which.sub %in% levels(X$subclass)])
warning(paste(w.l, ifelse(attr(w.l, "plural"), "do", "does"), "not correspond to any subclass in the object and will be ignored."), call. = FALSE)
which.sub <- which.sub[which.sub %in% levels(X$subclass)]
}
Expand Down Expand Up @@ -160,7 +160,7 @@ bal.plot <- function(obj, var.name, ..., which, which.sub = NULL, cluster = NULL
in.imp <- !is.na(X$imp) & sapply(X$imp, function(x) !is.na(match(x, levels(X$imp)[which.imp])))
}
else {
stop(paste0("The following inputs to which.imp do not correspond to given imputations:\n\t", word.list(which.imp[!which.imp %in% seq_len(nlevels(X$imp))])), call. = FALSE)
stop(paste0("The following inputs to which.imp do not correspond to given imputations:\n\t", word_list(which.imp[!which.imp %in% seq_len(nlevels(X$imp))])), call. = FALSE)
}
}
else stop("The argument to which.imp must be the indices corresponding to the imputations for which distributions are to be displayed.", call. = FALSE)
Expand All @@ -182,15 +182,15 @@ bal.plot <- function(obj, var.name, ..., which, which.sub = NULL, cluster = NULL
in.cluster <- !is.na(X$cluster) & sapply(X$cluster, function(x) !is.na(match(x, levels(X$cluster)[which.cluster])))
}
else {
stop(paste0("The following inputs to which.cluster do not correspond to given clusters:\n\t", word.list(which.cluster[!which.cluster %in% seq_len(nlevels(X$cluster))])), call. = FALSE)
stop(paste0("The following inputs to which.cluster do not correspond to given clusters:\n\t", word_list(which.cluster[!which.cluster %in% seq_len(nlevels(X$cluster))])), call. = FALSE)
}
}
else if (is.character(which.cluster)) {
if (all(!is.na(match(which.cluster, levels(X$cluster))))) {
in.cluster <- !is.na(X$cluster) & sapply(X$cluster, function(x) !is.na(match(x, which.cluster)))
}
else {
stop(paste0("The following inputs to which.cluster do not correspond to given clusters:\n\t", word.list(which.cluster[is.na(match(which.cluster, levels(X$cluster)))])), call. = FALSE)
stop(paste0("The following inputs to which.cluster do not correspond to given clusters:\n\t", word_list(which.cluster[is.na(match(which.cluster, levels(X$cluster)))])), call. = FALSE)
}
}
else stop("The argument to which.cluster must be the names or indices corresponding to the clusters for which distributions are to be displayed.", call. = FALSE)
Expand All @@ -213,16 +213,16 @@ bal.plot <- function(obj, var.name, ..., which, which.sub = NULL, cluster = NULL
#nothing; which.time is good
}
else if (any(which.time %in% seq_along(X$covs.list)[appears.in.time])) {
warning(paste0(var.name, " does not appear in time period ", word.list(which.time[!which.time %in% seq_along(X$covs.list)[appears.in.time]], "or"), "."), call. = FALSE)
warning(paste0(var.name, " does not appear in time period ", word_list(which.time[!which.time %in% seq_along(X$covs.list)[appears.in.time]], "or"), "."), call. = FALSE)
which.time <- which.time[which.time %in% seq_along(X$covs.list)[appears.in.time]]
}
else {
stop(paste0(var.name, " does not appear in time period ", word.list(which.time, "or"), "."), call. = FALSE)
stop(paste0(var.name, " does not appear in time period ", word_list(which.time, "or"), "."), call. = FALSE)
}
in.time <- !is.na(X$time) & X$time %in% which.time
}
else {
stop(paste0("The following inputs to which.time do not correspond to given time periods:\n\t", word.list(which.time[!which.time %in% seq_along(X$covs.list)])), call. = FALSE)
stop(paste0("The following inputs to which.time do not correspond to given time periods:\n\t", word_list(which.time[!which.time %in% seq_along(X$covs.list)])), call. = FALSE)
}
}
else if (is.character(which.time)) {
Expand All @@ -231,14 +231,14 @@ bal.plot <- function(obj, var.name, ..., which, which.sub = NULL, cluster = NULL
#nothing; which.time is good
}
else if (any(which.time %in% treat.names[appears.in.time])) {
time.periods <- word.list(which.time[!which.time %in% treat.names[appears.in.time]], "and")
time.periods <- word_list(which.time[!which.time %in% treat.names[appears.in.time]], "and")
warning(paste0(var.name, " does not appear in the time period", ifelse(attr(time.periods, "plural"), "s ", " "),
"corresponding to treatment", ifelse(attr(time.periods, "plural"), "s ", " "),
time.periods, "."), call. = FALSE)
which.time <- which.time[which.time %in% treat.names[appears.in.time]]
}
else {
time.periods <- word.list(which.time, "and")
time.periods <- word_list(which.time, "and")
stop(paste0(var.name, " does not appear in the time period", ifelse(attr(time.periods, "plural"), "s ", " "),
"corresponding to treatment", ifelse(attr(time.periods, "plural"), "s ", " "),
time.periods, "."), call. = FALSE)
Expand All @@ -247,7 +247,7 @@ bal.plot <- function(obj, var.name, ..., which, which.sub = NULL, cluster = NULL

}
else {
stop(paste0("The following inputs to which.time do not correspond to given time periods:\n\t", word.list(which.time[!which.time %in% treat.names])), call. = FALSE)
stop(paste0("The following inputs to which.time do not correspond to given time periods:\n\t", word_list(which.time[!which.time %in% treat.names])), call. = FALSE)
}
}
else stop("The argument to which.time must be the names or indices corresponding to the time periods for which distributions are to be displayed.", call. = FALSE)
Expand Down
24 changes: 12 additions & 12 deletions R/get.w.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ get.w.ps <- function(x, stop.method = NULL, estimand = NULL, s.weights = FALSE,
if (any(is.character(stop.method))) {
rule1 <- names(ps$w)[pmatch(tolower(names(ps$w)), tolower(stop.method), 0L)]
if (is_null(rule1)) {
message(paste0("Warning: stop.method should be ", word.list(names(ps$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
message(paste0("Warning: stop.method should be ", word_list(names(ps$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
rule1 <- names(ps$w)
}
}
else if (is.numeric(stop.method) && any(stop.method %in% seq_along(names(ps$w)))) {
if (any(!stop.method %in% seq_along(names(ps$w)))) {
message(paste0("Warning: There are ", length(names(ps$w)), " stop methods available, but you requested ",
word.list(stop.method[!stop.method %in% seq_along(names(ps$w))], and.or = "and"),"."))
word_list(stop.method[!stop.method %in% seq_along(names(ps$w))], and.or = "and"),"."))
}
rule1 <- names(ps$w)[stop.method %in% seq_along(names(ps$w))]
}
else {
warning("stop.method should be ", word.list(names(ps$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
warning("stop.method should be ", word_list(names(ps$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
rule1 <- names(ps$w)
}
}
Expand Down Expand Up @@ -62,19 +62,19 @@ get.w.mnps <- function(x, stop.method = NULL, s.weights = FALSE, ...) {
if (is.character(stop.method)) {
rule1 <- mnps$stopMethods[pmatch(tolower(stop.method), tolower(mnps$stopMethods), nomatch = 0L)]
if (is_null(rule1)) {
message(paste0("Warning: stop.method should be ", word.list(mnps$stopMethods, and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
message(paste0("Warning: stop.method should be ", word_list(mnps$stopMethods, and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
rule1 <- mnps$stopMethods
}
}
else if (is.numeric(stop.method) && any(stop.method %in% seq_along(mnps$stopMethods))) {
if (any(!stop.method %in% seq_along(mnps$stopMethods))) {
message(paste0("Warning: There are ", length(mnps$stopMethods), " stop methods available, but you requested ",
word.list(stop.method[!stop.method %in% seq_along(mnps$stopMethods)], and.or = "and"),"."))
word_list(stop.method[!stop.method %in% seq_along(mnps$stopMethods)], and.or = "and"),"."))
}
rule1 <- mnps$stopMethods[stop.method %in% seq_along(mnps$stopMethods)]
}
else {
warning("stop.method should be ", word.list(mnps$stopMethods, and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
warning("stop.method should be ", word_list(mnps$stopMethods, and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
rule1 <- mnps$stopMethods
}
}
Expand Down Expand Up @@ -128,20 +128,20 @@ get.w.ps.cont <- function(x, stop.method = NULL, s.weights = FALSE, ...) {
if (any(is.character(stop.method))) {
rule1 <- names(ps.cont$w)[pmatch(tolower(names(ps.cont$w)), tolower(stop.method), 0L)]
if (is_null(rule1)) {
message(paste0("Warning: stop.method should be ", word.list(names(ps.cont$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
message(paste0("Warning: stop.method should be ", word_list(names(ps.cont$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
rule1 <- names(ps.cont$w)
}

}
else if (is.numeric(stop.method) && any(stop.method %in% seq_along(names(ps.cont$w)))) {
if (any(!stop.method %in% seq_along(names(ps.cont$w)))) {
message(paste0("Warning: There are ", length(names(ps.cont$w)), " stop methods available, but you requested ",
word.list(stop.method[!stop.method %in% seq_along(names(ps.cont$w))], and.or = "and"),"."))
word_list(stop.method[!stop.method %in% seq_along(names(ps.cont$w))], and.or = "and"),"."))
}
rule1 <- names(ps.cont$w)[stop.method %in% seq_along(names(ps.cont$w))]
}
else {
warning("stop.method should be ", word.list(names(ps.cont$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
warning("stop.method should be ", word_list(names(ps.cont$w), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
rule1 <- names(ps.cont$w)
}
}
Expand Down Expand Up @@ -169,19 +169,19 @@ get.w.iptw <- function(x, stop.method = NULL, s.weights = FALSE, ...) {
if (any(is.character(stop.method))) {
rule1 <- names(iptw$psList[[1]]$ps)[pmatch(tolower(names(iptw$psList[[1]]$ps)), tolower(stop.method), 0L)]
if (is_null(rule1)) {
message(paste0("Warning: stop.method should be ", word.list(names(iptw$psList[[1]]$ps), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
message(paste0("Warning: stop.method should be ", word_list(names(iptw$psList[[1]]$ps), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead."))
rule1 <- names(iptw$psList[[1]]$ps)
}
}
else if (is.numeric(stop.method) && any(stop.method %in% seq_along(names(iptw$psList[[1]]$ps)))) {
if (any(!stop.method %in% seq_along(names(iptw$psList[[1]]$ps)))) {
message(paste0("Warning: There are ", length(names(iptw$psList[[1]]$ps)), " stop methods available, but you requested ",
word.list(stop.method[!stop.method %in% seq_along(names(iptw$psList[[1]]$ps))], and.or = "and"),"."))
word_list(stop.method[!stop.method %in% seq_along(names(iptw$psList[[1]]$ps))], and.or = "and"),"."))
}
rule1 <- names(iptw$psList[[1]]$ps)[stop.method %in% seq_along(names(iptw$psList[[1]]$ps))]
}
else {
warning("stop.method should be ", word.list(names(iptw$psList[[1]]$ps), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
warning("stop.method should be ", word_list(names(iptw$psList[[1]]$ps), and.or = "or", quotes = TRUE), ".\nUsing all available stop methods instead.", call. = FALSE)
rule1 <- names(iptw$psList[[1]]$ps)
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/love.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ love.plot <- function(x, stat = "mean.diffs", threshold = NULL,
missing.stats <- vapply(which.stat, function(s) {
all(is.na(SS[["mean.stat"]][SS[["Statistic"]] == which.stat2[s]]))
}, logical(1L))
if (any(missing.stats)) stop(paste0(word.list(firstup(tolower(which.stat2[which.stat[missing.stats]]))), " cannot be displayed. This can occur when ", word.list(paste.("disp", tolower(which.stat[missing.stats])), and.or = "and", is.are = TRUE), " FALSE and quick = TRUE in the original call to bal.tab()."), call. = FALSE)
if (any(missing.stats)) stop(paste0(word_list(firstup(tolower(which.stat2[which.stat[missing.stats]]))), " cannot be displayed. This can occur when ", word_list(paste.("disp", tolower(which.stat[missing.stats])), and.or = "and", is.are = TRUE), " FALSE and quick = TRUE in the original call to bal.tab()."), call. = FALSE)

gone <- character(0)
for (i in levels(SS$Sample)) {
Expand Down Expand Up @@ -828,7 +828,7 @@ love.plot <- function(x, stat = "mean.diffs", threshold = NULL,
missing.stats <- vapply(which.stat, function(s) {
all(is.na(SS[["stat"]][SS[["Statistic"]] == which.stat2[s]]))
}, logical(1L))
if (any(missing.stats)) stop(paste0(word.list(firstup(tolower(which.stat2[which.stat[missing.stats]]))), " cannot be displayed. This can occur when ", word.list(paste.("disp", tolower(which.stat[missing.stats])), and.or = "and"), " are FALSE and quick = TRUE in the original call to bal.tab()."), call. = FALSE)
if (any(missing.stats)) stop(paste0(word_list(firstup(tolower(which.stat2[which.stat[missing.stats]]))), " cannot be displayed. This can occur when ", word_list(paste.("disp", tolower(which.stat[missing.stats])), and.or = "and"), " are FALSE and quick = TRUE in the original call to bal.tab()."), call. = FALSE)

gone <- character(0)
for (i in levels(SS$Sample)) {
Expand Down
8 changes: 4 additions & 4 deletions R/print.bal.tab.R
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ print.bal.tab.cluster <- function(x, disp.m.threshold = "as.is", disp.v.threshol
p.ops$cluster.fun <- cluster.fun
}
if (is_not_null(p.ops$cluster.fun)) {
if (!is.character(p.ops$cluster.fun)) stop(paste0("cluster.fun must be ", word.list(c(cluster.funs, "as.is"), and.or = "or", quotes = TRUE)))
if (!is.character(p.ops$cluster.fun)) stop(paste0("cluster.fun must be ", word_list(c(cluster.funs, "as.is"), and.or = "or", quotes = TRUE)))
p.ops$cluster.fun <- match_arg(tolower(p.ops$cluster.fun), cluster.funs, several.ok = TRUE)
if (is_null(p.ops$cluster.fun)) {
warning("There were no valid entries to cluster.fun. Using the default cluster.funs instead.", call. = FALSE)
Expand Down Expand Up @@ -895,7 +895,7 @@ print.bal.tab.imp <- function(x, disp.m.threshold = "as.is", disp.v.threshold =
p.ops$imp.fun <- imp.fun
}
if (is_not_null(p.ops$imp.fun)) {
if (!is.character(p.ops$imp.fun)) stop(paste0("imp.fun must be ", word.list(c(imp.funs, "as.is"), and.or = "or", quotes = TRUE)))
if (!is.character(p.ops$imp.fun)) stop(paste0("imp.fun must be ", word_list(c(imp.funs, "as.is"), and.or = "or", quotes = TRUE)))
p.ops$imp.fun <- match_arg(tolower(p.ops$imp.fun), imp.funs, several.ok = TRUE)
if (is_null(p.ops$imp.fun)) {
warning("There were no valid entries to imp.fun. Using the default imp.funs instead.", call. = FALSE)
Expand Down Expand Up @@ -1162,7 +1162,7 @@ print.bal.tab.imp.cluster <- function(x, disp.m.threshold = "as.is", disp.v.thre
p.ops$cluster.fun <- cluster.fun
}
if (is_not_null(p.ops$cluster.fun)) {
if (!is.character(p.ops$cluster.fun)) stop(paste0("cluster.fun must be ", word.list(c(cluster.funs, "as.is"), and.or = "or", quotes = TRUE)))
if (!is.character(p.ops$cluster.fun)) stop(paste0("cluster.fun must be ", word_list(c(cluster.funs, "as.is"), and.or = "or", quotes = TRUE)))
p.ops$cluster.fun <- match_arg(tolower(p.ops$cluster.fun), cluster.funs, several.ok = TRUE)
if (is_null(p.ops$cluster.fun)) {
warning("There were no valid entries to cluster.fun. Using the default cluster.funs instead.", call. = FALSE)
Expand Down Expand Up @@ -1210,7 +1210,7 @@ print.bal.tab.imp.cluster <- function(x, disp.m.threshold = "as.is", disp.v.thre
p.ops$imp.fun <- imp.fun
}
if (is_not_null(p.ops$imp.fun)) {
if (!is.character(p.ops$imp.fun)) stop(paste0("imp.fun must be ", word.list(c(imp.funs, "as.is"), and.or = "or", quotes = TRUE)))
if (!is.character(p.ops$imp.fun)) stop(paste0("imp.fun must be ", word_list(c(imp.funs, "as.is"), and.or = "or", quotes = TRUE)))
p.ops$imp.fun <- match_arg(tolower(p.ops$imp.fun), imp.funs, several.ok = TRUE)
if (is_null(p.ops$imp.fun)) {
warning("There were no valid entries to imp.fun. Using the default imp.funs instead.", call. = FALSE)
Expand Down
Loading

0 comments on commit c742bdb

Please sign in to comment.