Skip to content

Commit 9321b7b

Browse files
fixes #11
1 parent 7340057 commit 9321b7b

File tree

8 files changed

+401
-335
lines changed

8 files changed

+401
-335
lines changed

R/infer-binom-test.R

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
#' \item{exp_k}{expected number of successes}
1717
#' \item{obs_p}{assumed probability of success}
1818
#' \item{exp_p}{expected probability of success}
19-
#' \item{ik}{the largest number <= \code{exp_k} such that Pr(k = ik) <= Pr(k = kobs)}
2019
#' \item{lower}{lower one sided p value}
2120
#' \item{upper}{upper one sided p value}
22-
#' \item{two_tail}{two sided p value}
2321
#' @section Deprecated Functions:
2422
#' \code{binom_calc()} and \code{binom_test()} have been deprecated. Instead use
2523
#' \code{infer_binom_cal()} and \code{infer_binom_test()}.
@@ -59,8 +57,7 @@ infer_binom_calc.default <- function(n, success, prob = 0.5, ...) {
5957
k <- binom_comp(n, success, prob)
6058

6159
out <- list(n = n, k = k$k, exp_k = k$exp_k, obs_p = k$obs_p,
62-
exp_p = k$exp_p, ik = k$ik, lower = k$lower, upper = k$upper,
63-
two_tail = k$two_tail)
60+
exp_p = k$exp_p, lower = k$lower, upper = k$upper)
6461

6562
class(out) <- 'infer_binom_calc'
6663
return(out)

R/infer-output.R

+24-24
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ print_binom <- function(data) {
8181

8282
# test summary widths
8383
w6 <- nchar('Lower')
84-
w7 <- nchar(paste0('Pr(k <= ', data$ik, ' or k >= ', data$k, ')'))
85-
w8 <- nchar(paste0('Pr(k <= ', data$k, ' or k >= ', data$ik, ')'))
84+
w7 <- nchar(paste0('Pr(k <= ', data$k, ' or k >= ', data$k, ')'))
85+
w8 <- nchar(paste0('Pr(k <= ', data$k, ' or k >= ', data$k, ')'))
8686
w9 <- 8
8787
w10 <- sum(w6, w7, w9, 9)
8888
w11 <- sum(w6, w8, w9, 9)
@@ -97,17 +97,17 @@ print_binom <- function(data) {
9797
cat(" ", format('Tail', width = w6, justify = 'left'), fs(), format('Prob', width = w8, justify = 'centre'), fs(),
9898
format('p-value', width = w9, justify = 'centre'),'\n')
9999
cat(" ", rep("-", w11), sep = "", '\n')
100-
cat(" ", format('Lower', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$k, ')'), width = w8, justify = 'left'), fs(),
101-
format(data$lower, width = w9, justify = 'centre'),'\n')
102-
cat(" ", format('Upper', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$k, ')'), width = w8, justify = 'left'), fs(),
103-
format(data$upper, width = w9, justify = 'centre'),'\n')
104-
if (data$ik < 0) {
105-
cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$ik, ')'), width = w8, justify = 'left'), fs(),
106-
format(data$two_tail, width = w9, justify = 'centre'),'\n')
107-
} else {
108-
cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$k, ' or k >= ', data$ik, ')'), width = w8, justify = 'left'), fs(),
109-
format(data$two_tail, width = w9, justify = 'centre'),'\n')
110-
}
100+
cat(" ", format('Lower', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$k, ')'), width = w8, justify = 'centre'), fs(),
101+
format(as.character(data$lower), width = w9, justify = 'centre'),'\n')
102+
cat(" ", format('Upper', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$k, ')'), width = w8, justify = 'centre'), fs(),
103+
format(as.character(data$upper), width = w9, justify = 'centre'),'\n')
104+
# if (data$ik < 0) {
105+
# cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$ik, ')'), width = w8, justify = 'left'), fs(),
106+
# format(data$two_tail, width = w9, justify = 'centre'),'\n')
107+
# } else {
108+
# cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$k, ' or k >= ', data$ik, ')'), width = w8, justify = 'left'), fs(),
109+
# format(data$two_tail, width = w9, justify = 'centre'),'\n')
110+
# }
111111
cat(" ", rep("-", w11), sep = "", '\n')
112112

113113
} else {
@@ -117,17 +117,17 @@ print_binom <- function(data) {
117117
cat(" ", format('Tail', width = w6, justify = 'left'), fs(), format('Prob', width = w7, justify = 'centre'), fs(),
118118
format('p-value', width = w9, justify = 'centre'),'\n')
119119
cat(" ", rep("-", w10), sep = "", '\n')
120-
cat(" ", format('Lower', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$k, ')'), width = w7, justify = 'left'), fs(),
121-
format(data$lower, width = w9, justify = 'centre'),'\n')
122-
cat(" ", format('Upper', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$k, ')'), width = w7, justify = 'left'), fs(),
123-
format(data$upper, width = w9, justify = 'centre'),'\n')
124-
if (data$ik < 0) {
125-
cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$k, ')'), width = w7, justify = 'left'), fs(),
126-
format(data$two_tail, width = w9, justify = 'centre'),'\n')
127-
} else {
128-
cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$ik, ' or k >= ', data$k, ')'), width = w7, justify = 'left'), fs(),
129-
format(data$two_tail, width = w9, justify = 'centre'),'\n')
130-
}
120+
cat(" ", format('Lower', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$k, ')'), width = w7, justify = 'centre'), fs(),
121+
format(as.character(data$lower), width = w9, justify = 'centre'),'\n')
122+
cat(" ", format('Upper', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$k, ')'), width = w7, justify = 'centre'), fs(),
123+
format(as.character(data$upper), width = w9, justify = 'centre'),'\n')
124+
# if (data$ik < 0) {
125+
# cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k >= ', data$k, ')'), width = w7, justify = 'left'), fs(),
126+
# format(data$two_tail, width = w9, justify = 'centre'),'\n')
127+
# } else {
128+
# cat(" ", format('Two', width = w6, justify = 'left'), fs(), format(paste0('Pr(k <= ', data$ik, ' or k >= ', data$k, ')'), width = w7, justify = 'left'), fs(),
129+
# format(data$two_tail, width = w9, justify = 'centre'),'\n')
130+
# }
131131
cat(" ", rep("-", w10), sep = "", '\n')
132132

133133
}

docs/articles/index.html

+7-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)