diff --git a/DESCRIPTION b/DESCRIPTION index 5ed5b90..4833aa6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: vistributions Type: Package Title: Visualize Probability Distributions -Version: 0.1.1.9000 +Version: 0.1.2 Authors@R: person("Aravind", "Hebbali", email = "hebbali.aravind@gmail.com", role = c("aut", "cre")) Description: Visualize and compute percentiles/probabilities of normal, t, f, chi square and binomial distributions. Depends: - R(>= 3.1) + R(>= 3.2) Imports: ggplot2, magrittr, @@ -23,6 +23,5 @@ License: MIT + file LICENSE URL: https://github.com/rsquaredacademy/vistributions, https://vistributions.rsquaredacademy.com BugReports: https://github.com/rsquaredacademy/vistributions/issues Encoding: UTF-8 -LazyData: true RoxygenNote: 7.1.1 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index c1a8f6b..88bbf71 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,7 +16,7 @@ export(vdist_normal_prob) export(vdist_t_perc) export(vdist_t_plot) export(vdist_t_prob) -importFrom(magrittr,"%>%") -importFrom(utils,install.packages) -importFrom(utils,menu) -importFrom(utils,packageVersion) +import(ggplot2) +import(magrittr) +import(stats) +import(utils) diff --git a/NEWS.md b/NEWS.md index 908b31f..ed97213 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# vistributions 0.1.2 + +This is a patch release to fix CRAN note about lazy data. + # vistributions 0.1.1 This is a patch release to fix bugs in the app. diff --git a/R/vdist-binomial.R b/R/vdist-binomial.R index 7fbaf2d..aec0b1b 100644 --- a/R/vdist-binomial.R +++ b/R/vdist-binomial.R @@ -42,19 +42,19 @@ vdist_binom_plot <- function(n = 10, p = 0.3, print_plot = TRUE) { xn <- n / 40 bm <- round(n * p, 2) bsd <- round(sqrt((1 - p) * bm) , 2) - data <- stats::dbinom(x, n, p) + data <- dbinom(x, n, p) plot_data <- data.frame(n = seq(0, n), df = data) pp <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_col(ggplot2::aes(x = n, y = df), fill = "blue") + - ggplot2::ylab("Probability") + ggplot2::xlab("No. of success") + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggplot(plot_data) + + geom_col(aes(x = n, y = df), fill = "blue") + + ylab("Probability") + xlab("No. of success") + + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste("Mean =", bm, ", Std. Dev. =", bsd)) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + - ggplot2::scale_x_continuous(breaks = seq(0, n)) + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) + + scale_x_continuous(breaks = seq(0, n)) if (print_plot) { print(pp) @@ -95,49 +95,49 @@ vdist_binom_prob <- function(n = 10, p = 0.3, s = 4, bsd <- round(sqrt((1 - p) * bm), 2) if (method == "lower") { - k <- round(stats::pbinom(s, n, p), 3) - cols <- ifelse(cumsum(round(stats::dbinom(x, n, p), 3)) <= k, "#0000CD", "#6495ED") + k <- round(pbinom(s, n, p), 3) + cols <- ifelse(cumsum(round(dbinom(x, n, p), 3)) <= k, "#0000CD", "#6495ED") } else if (method == "upper") { - k <- round(1 - stats::pbinom((s - 1), n, p), 3) - cols <- ifelse(cumsum(round(stats::dbinom(x, n, p), 3)) >= k, "#0000CD", "#6495ED") + k <- round(1 - pbinom((s - 1), n, p), 3) + cols <- ifelse(cumsum(round(dbinom(x, n, p), 3)) >= k, "#0000CD", "#6495ED") } else if (method == "exact") { - k <- stats::pbinom(s, n, p) - stats::pbinom((s - 1), n, p) - cols <- ifelse(round(stats::dbinom(x, n, p), 5) == round(k, 5), "#0000CD", "#6495ED") + k <- pbinom(s, n, p) - pbinom((s - 1), n, p) + cols <- ifelse(round(dbinom(x, n, p), 5) == round(k, 5), "#0000CD", "#6495ED") } else { - k1 <- stats::pbinom((s[1] - 1), n, p) - k2 <- stats::pbinom(s[2], n, p) - k <- stats::pbinom(s[2], n, p) - stats::pbinom((s[1] - 1), n, p) - cols <- ifelse((round(cumsum(stats::dbinom(x, n, p)), 6) > round(k1, 6) & - round(cumsum(stats::dbinom(x, n, p)), 6) <= round(k2, 6)), "#0000CD", "#6495ED") + k1 <- pbinom((s[1] - 1), n, p) + k2 <- pbinom(s[2], n, p) + k <- pbinom(s[2], n, p) - pbinom((s[1] - 1), n, p) + cols <- ifelse((round(cumsum(dbinom(x, n, p)), 6) > round(k1, 6) & + round(cumsum(dbinom(x, n, p)), 6) <= round(k2, 6)), "#0000CD", "#6495ED") } - data <- stats::dbinom(x, n, p) + data <- dbinom(x, n, p) plot_data <- data.frame(n = seq(0, n), df = data) pp <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_col(ggplot2::aes(x = n, y = df), fill = cols) + - ggplot2::ylab("Probability") + - ggplot2::xlab(paste("No. of success\n", "Mean =", bm, ", Std. Dev. =", bsd)) + - ggplot2::scale_x_continuous(breaks = seq(0, n)) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_col(aes(x = n, y = df), fill = cols) + + ylab("Probability") + + xlab(paste("No. of success\n", "Mean =", bm, ", Std. Dev. =", bsd)) + + scale_x_continuous(breaks = seq(0, n)) + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { pp + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste("P(X) <=", s, "=", round(k, 3))) } else if (method == "upper") { pp + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste("P(X) >=", s, "=", round(k, 3))) } else if (method == "exact") { pp + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste("P(X) =", s, "=", round(k, 3))) } else { pp + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste0("P(", s[1], " <= X <= ", s[2], ")", " = ", round(k, 3))) } @@ -166,33 +166,33 @@ vdist_binom_perc <- function(n = 10, p = 0.5, tp = 0.05, type = c("lower", "uppe x <- seq(0, n, 1) if (method == "lower") { - k <- round(stats::qbinom(tp, n, p), 3) - cols <- ifelse(cumsum(stats::dbinom(x, n, p)) <= stats::pbinom(k, n, p), "#0000CD", "#6495ED") + k <- round(qbinom(tp, n, p), 3) + cols <- ifelse(cumsum(dbinom(x, n, p)) <= pbinom(k, n, p), "#0000CD", "#6495ED") } else { - k <- round(stats::qbinom(tp, n, p, lower.tail = F), 3) - cols <- ifelse(cumsum(stats::dbinom(x, n, p)) > stats::pbinom((k + 1), n, p), "#0000CD", "#6495ED") + k <- round(qbinom(tp, n, p, lower.tail = F), 3) + cols <- ifelse(cumsum(dbinom(x, n, p)) > pbinom((k + 1), n, p), "#0000CD", "#6495ED") } - data <- stats::dbinom(x, n, p) + data <- dbinom(x, n, p) plot_data <- data.frame(n = seq(0, n), df = data) pp <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_col(ggplot2::aes(x = n, y = df), fill = cols) + - ggplot2::ylab("Probability") + ggplot2::xlab("No. of success") + - ggplot2::scale_x_continuous(breaks = seq(0, n)) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_col(aes(x = n, y = df), fill = cols) + + ylab("Probability") + xlab("No. of success") + + scale_x_continuous(breaks = seq(0, n)) + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { pp + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste0("P(X <= ", k, ") <= ", tp, ", but P(X <= ", (k + 1), ") > ", tp)) } else { pp + - ggplot2::ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), + ggtitle(label = paste("Binomial Distribution: n =", n, ", p =", p), subtitle = paste0("P(X >= ", (k + 1), ") <= ", tp, ", but P(X >= ", k, ") > ", tp)) } diff --git a/R/vdist-chisquare.R b/R/vdist-chisquare.R index caaa2fd..bf1ffd6 100644 --- a/R/vdist-chisquare.R +++ b/R/vdist-chisquare.R @@ -41,30 +41,30 @@ vdist_chisquare_plot <- function(df = 3, normal = FALSE, chim <- round(df, 3) chisd <- round(sqrt(2 * df), 3) x <- seq(0, xaxis_range, 0.01) - data <- stats::dchisq(x, df) + data <- dchisq(x, df) plot_data <- data.frame(x = x, chi = data) poly_data <- data.frame(y = c(0, seq(0, 25, 0.01), 25), - z = c(0, stats::dchisq(seq(0, 25, 0.01), df), 0)) + z = c(0, dchisq(seq(0, 25, 0.01), df), 0)) point_data <- data.frame(x = chim, y = min(data)) - nline_data <- data.frame(x = x, y = stats::dnorm(x, chim, chisd)) + nline_data <- data.frame(x = x, y = dnorm(x, chim, chisd)) pp <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x, chi), color = '#4682B4', size = 2) + - ggplot2::ggtitle(label = "Chi Square Distribution", + ggplot(plot_data) + + geom_line(aes(x, chi), color = '#4682B4', size = 2) + + ggtitle(label = "Chi Square Distribution", subtitle = paste("df =", df)) + - ggplot2::ylab('') + - ggplot2::xlab(paste("Mean =", chim, " Std Dev. =", chisd)) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + - ggplot2::scale_x_continuous(breaks = seq(0, xaxis_range, 2)) + - ggplot2::geom_polygon(data = poly_data, - mapping = ggplot2::aes(x = y, y = z), + ylab('') + + xlab(paste("Mean =", chim, " Std Dev. =", chisd)) + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) + + scale_x_continuous(breaks = seq(0, xaxis_range, 2)) + + geom_polygon(data = poly_data, + mapping = aes(x = y, y = z), fill = '#4682B4') + - ggplot2::geom_point(data = point_data, - mapping = ggplot2::aes(x = x, y = y), + geom_point(data = point_data, + mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) @@ -73,7 +73,7 @@ vdist_chisquare_plot <- function(df = 3, normal = FALSE, if (normal) { pp <- pp + - ggplot2::geom_line(data = nline_data, mapping = ggplot2::aes(x = x, y = y), + geom_line(data = nline_data, mapping = aes(x = x, y = y), color = '#FF4500') } @@ -104,13 +104,13 @@ vdist_chisquare_perc <- function(probs = 0.95, df = 3, ln <- length(l) if (method == "lower") { - pp <- round(stats::qchisq(probs, df), 3) + pp <- round(qchisq(probs, df), 3) lc <- c(l[1], pp, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else { - pp <- round(stats::qchisq(probs, df, lower.tail = F), 3) + pp <- round(qchisq(probs, df, lower.tail = F), 3) lc <- c(l[1], pp, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) @@ -118,49 +118,49 @@ vdist_chisquare_perc <- function(probs = 0.95, df = 3, } xm <- vdist_xmm(chim, chisd) - plot_data <- data.frame(x = l, y = stats::dchisq(l, df)) + plot_data <- data.frame(x = l, y = dchisq(l, df)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y), color = "blue") + - ggplot2::xlab(paste("Mean =", chim, " Std Dev. =", chisd)) + - ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(aes(x = x, y = y), color = "blue") + + xlab(paste("Mean =", chim, " Std Dev. =", chisd)) + + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = paste("Chi Square Distribution: df =", df), + ggtitle(label = paste("Chi Square Distribution: df =", df), subtitle = paste0("P(X < ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", + annotate("text", label = paste0(probs * 100, "%"), x = pp - chisd, - y = max(stats::dchisq(l, df)) + 0.02, + y = max(dchisq(l, df)) + 0.02, color = "#0000CD", size = 3) + - ggplot2::annotate("text", + annotate("text", label = paste0((1 - probs) * 100, "%"), x = pp + chisd, - y = max(stats::dchisq(l, df)) + 0.02, + y = max(dchisq(l, df)) + 0.02, color = "#6495ED", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = paste("Chi Square Distribution: df =", df), + ggtitle(label = paste("Chi Square Distribution: df =", df), subtitle = paste0("P(X > ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", + annotate("text", label = paste0((1 - probs) * 100, "%"), x = pp - chisd, - y = max(stats::dchisq(l, df)) + 0.02, + y = max(dchisq(l, df)) + 0.02, color = "#6495ED", size = 3) + - ggplot2::annotate("text", + annotate("text", label = paste0(probs * 100, "%"), x = pp + chisd, - y = max(stats::dchisq(l, df)) + 0.02, + y = max(dchisq(l, df)) + 0.02, color = "#0000CD", size = 3) } @@ -169,25 +169,25 @@ vdist_chisquare_perc <- function(probs = 0.95, df = 3, pol_data <- vdist_pol_chi(lc[l1[i]], lc[l2[i]], df) gplot <- gplot + - ggplot2::geom_polygon(data = pol_data, - mapping = ggplot2::aes(x = x, y = y), + geom_polygon(data = pol_data, + mapping = aes(x = x, y = y), fill = col[i]) } - point_data <- data.frame(x = pp, y = min(stats::dchisq(l, df))) + point_data <- data.frame(x = pp, y = min(dchisq(l, df))) gplot <- gplot + - ggplot2::geom_vline(xintercept = pp, + geom_vline(xintercept = pp, linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, - mapping = ggplot2::aes(x = x, y = y), + geom_point(data = point_data, + mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = seq(0, xm[2], by = 5)) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = seq(0, xm[2], by = 5)) if (print_plot) { print(gplot) @@ -219,51 +219,51 @@ vdist_chisquare_prob <- function(perc = 13, df = 11, type = c("lower", "upper"), ln <- length(l) if (method == "lower") { - pp <- round(stats::pchisq(perc, df), 3) + pp <- round(pchisq(perc, df), 3) lc <- c(l[1], perc, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else { - pp <- round(stats::pchisq(perc, df, lower.tail = F), 3) + pp <- round(pchisq(perc, df, lower.tail = F), 3) lc <- c(l[1], perc, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) l2 <- c(2, 3) } - plot_data <- data.frame(x = l, y = stats::dchisq(l, df)) + plot_data <- data.frame(x = l, y = dchisq(l, df)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y), color = "blue") + - ggplot2::xlab(paste("Mean =", chim, " Std Dev. =", chisd)) + - ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(aes(x = x, y = y), color = "blue") + + xlab(paste("Mean =", chim, " Std Dev. =", chisd)) + + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = paste("Chi Square Distribution: df =", df), + ggtitle(label = paste("Chi Square Distribution: df =", df), subtitle = paste0("P(X < ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc - chisd, y = max(stats::dchisq(l, df)) + 0.02, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc - chisd, y = max(dchisq(l, df)) + 0.02, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0((1 - pp) * 100, "%"), - x = perc + chisd, y = max(stats::dchisq(l, df)) + 0.02, color = "#6495ED", + annotate("text", label = paste0((1 - pp) * 100, "%"), + x = perc + chisd, y = max(dchisq(l, df)) + 0.02, color = "#6495ED", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = paste("Chi Square Distribution: df =", df), + ggtitle(label = paste("Chi Square Distribution: df =", df), subtitle = paste0("P(X > ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - pp) * 100, "%"), - x = perc - chisd, y = max(stats::dchisq(l, df)) + 0.02, color = "#6495ED", + annotate("text", label = paste0((1 - pp) * 100, "%"), + x = perc - chisd, y = max(dchisq(l, df)) + 0.02, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc + chisd, y = max(stats::dchisq(l, df)) + 0.02, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc + chisd, y = max(dchisq(l, df)) + 0.02, color = "#0000CD", size = 3) } @@ -272,26 +272,26 @@ vdist_chisquare_prob <- function(perc = 13, df = 11, type = c("lower", "upper"), pol_data <- vdist_pol_chi(lc[l1[i]], lc[l2[i]], df) gplot <- gplot + - ggplot2::geom_polygon(data = pol_data, - mapping = ggplot2::aes(x = x, y = y), + geom_polygon(data = pol_data, + mapping = aes(x = x, y = y), fill = col[i]) } point_data <- data.frame(x = perc, - y = min(stats::dchisq(l, df))) + y = min(dchisq(l, df))) gplot <- gplot + - ggplot2::geom_vline(xintercept = perc, + geom_vline(xintercept = perc, linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, - mapping = ggplot2::aes(x = x, y = y), + geom_point(data = point_data, + mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = seq(0, l[ln], by = 5)) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = seq(0, l[ln], by = 5)) if (print_plot) { print(gplot) @@ -305,21 +305,18 @@ vdist_chisquare_prob <- function(perc = 13, df = 11, type = c("lower", "upper"), vdist_chiseql <- function(mean, sd) { lmin <- mean - (5 * sd) lmax <- mean + (5 * sd) - l <- seq(lmin, lmax, 0.01) - return(l) + seq(lmin, lmax, 0.01) } vdist_xmm <- function(mean, sd) { xmin <- mean - (5 * sd) xmax <- mean + (5 * sd) - out <- c(xmin, xmax) - return(out) + c(xmin, xmax) } vdist_pol_chi <- function(l1, l2, df) { x <- c(l1, seq(l1, l2, 0.01), l2) - y <- c(0, stats::dchisq(seq(l1, l2, 0.01), df), 0) - out <- data.frame(x = x, y = y) - return(out) + y <- c(0, dchisq(seq(l1, l2, 0.01), df), 0) + data.frame(x = x, y = y) } diff --git a/R/vdist-f.R b/R/vdist-f.R index f2bba79..5c79450 100644 --- a/R/vdist-f.R +++ b/R/vdist-f.R @@ -44,31 +44,31 @@ vdist_f_plot <- function(num_df = 4, den_df = 30, normal = FALSE, x <- seq(0, 4, 0.01) nx <- seq(-2, 4, 0.01) - plot_data <- data.frame(x = x, y = stats::df(x, num_df, den_df)) + plot_data <- data.frame(x = x, y = df(x, num_df, den_df)) poly_data <- data.frame(y = c(0, seq(0, 4, 0.01), 4), - z = c(0, stats::df(seq(0, 4, 0.01), num_df, den_df), 0)) + z = c(0, df(seq(0, 4, 0.01), num_df, den_df), 0)) point_data <- data.frame(x = fm, y = 0) - nline_data <- data.frame(x = nx, y = stats::dnorm(nx, fm, fsd)) + nline_data <- data.frame(x = nx, y = dnorm(nx, fm, fsd)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y), color = "blue") + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = y, y = z), + ggplot(plot_data) + + geom_line(aes(x = x, y = y), color = "blue") + + geom_polygon(data = poly_data, mapping = aes(x = y, y = z), fill = '#4682B4') + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) + - ggplot2::xlab(paste("Mean =", fm, " Std Dev. =", fsd)) + ggplot2::ylab('') + - ggplot2::ggtitle(label = 'f Distribution', + xlab(paste("Mean =", fm, " Std Dev. =", fsd)) + ylab('') + + ggtitle(label = 'f Distribution', subtitle = paste("Num df =", num_df, " Den df =", den_df)) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + - ggplot2::scale_x_continuous(breaks = c(-2:4)) + - ggplot2::scale_y_continuous(breaks = NULL) + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) + + scale_x_continuous(breaks = c(-2:4)) + + scale_y_continuous(breaks = NULL) if (normal) { gplot <- gplot + - ggplot2::geom_line(data = nline_data, mapping = ggplot2::aes(x = x, y = y), + geom_line(data = nline_data, mapping = aes(x = x, y = y), color = '#FF4500') } @@ -100,52 +100,52 @@ vdist_f_perc <- function(probs = 0.95, num_df = 3, den_df = 30, ln <- length(l) if (method == "lower") { - pp <- round(stats::qf(probs, num_df, den_df), 3) + pp <- round(qf(probs, num_df, den_df), 3) lc <- c(l[1], pp, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else { - pp <- round(stats::qf(probs, num_df, den_df, lower.tail = F), 3) + pp <- round(qf(probs, num_df, den_df, lower.tail = F), 3) lc <- c(l[1], pp, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) l2 <- c(2, 3) } - plot_data <- data.frame(x = l, y = stats::df(l, num_df, den_df)) + plot_data <- data.frame(x = l, y = df(l, num_df, den_df)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(data = plot_data, mapping = ggplot2::aes(x = x, y = y), - color = 'blue') + ggplot2::xlab(paste("Mean =", fm, " Std Dev. =", fsd)) + - ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(data = plot_data, mapping = aes(x = x, y = y), + color = 'blue') + xlab(paste("Mean =", fm, " Std Dev. =", fsd)) + + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = 'f Distribution', + ggtitle(label = 'f Distribution', subtitle = paste0("P(X < ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = pp - 0.2, y = max(stats::df(l, num_df, den_df)) + 0.02, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = pp - 0.2, y = max(df(l, num_df, den_df)) + 0.02, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0((1 - probs) * 100, "%"), - x = pp + 0.2, y = max(stats::df(l, num_df, den_df)) + 0.02, color = "#6495ED", + annotate("text", label = paste0((1 - probs) * 100, "%"), + x = pp + 0.2, y = max(df(l, num_df, den_df)) + 0.02, color = "#6495ED", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = 'f Distribution', + ggtitle(label = 'f Distribution', subtitle = paste0("P(X > ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - probs) * 100, "%"), - x = pp - 0.2, y = max(stats::df(l, num_df, den_df)) + 0.02, color = "#6495ED", + annotate("text", label = paste0((1 - probs) * 100, "%"), + x = pp - 0.2, y = max(df(l, num_df, den_df)) + 0.02, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = pp + 0.2, y = max(stats::df(l, num_df, den_df)) + 0.02, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = pp + 0.2, y = max(df(l, num_df, den_df)) + 0.02, color = "#0000CD", size = 3) } @@ -153,7 +153,7 @@ vdist_f_perc <- function(probs = 0.95, num_df = 3, den_df = 30, poly_data <- vdist_pol_f(lc[l1[i]], lc[l2[i]], num_df, den_df) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } @@ -165,15 +165,15 @@ vdist_f_perc <- function(probs = 0.95, num_df = 3, den_df = 30, gplot <- gplot + - ggplot2::geom_vline(xintercept = pp[i], linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = pp[i], linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } gplot <- gplot + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = 0:5) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = 0:5) if (print_plot) { print(gplot) @@ -207,51 +207,51 @@ vdist_f_prob <- function(perc = 2.35, num_df = 5, den_df = 32, type = c("lower", ln <- length(l) if (method == "lower") { - pp <- round(stats::pf(perc, num_df, den_df), 3) + pp <- round(pf(perc, num_df, den_df), 3) lc <- c(l[1], perc, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else { - pp <- round(stats::pf(perc, num_df, den_df, lower.tail = F), 3) + pp <- round(pf(perc, num_df, den_df, lower.tail = F), 3) lc <- c(l[1], perc, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) l2 <- c(2, 3) } - plot_data <- data.frame(x = l, y = stats::df(l, num_df, den_df)) + plot_data <- data.frame(x = l, y = df(l, num_df, den_df)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(data = plot_data, mapping = ggplot2::aes(x = x, y = y), - color = 'blue') + ggplot2::xlab(paste("Mean =", fm, " Std Dev. =", fsd)) + - ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(data = plot_data, mapping = aes(x = x, y = y), + color = 'blue') + xlab(paste("Mean =", fm, " Std Dev. =", fsd)) + + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = 'f Distribution', + ggtitle(label = 'f Distribution', subtitle = paste0("P(X < ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc - fsd, y = max(stats::df(l, num_df, den_df)) + 0.04, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc - fsd, y = max(df(l, num_df, den_df)) + 0.04, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(round((1 - pp) * 100, 2), "%"), - x = perc + fsd, y = max(stats::df(l, num_df, den_df)) + 0.02, color = "#6495ED", + annotate("text", label = paste0(round((1 - pp) * 100, 2), "%"), + x = perc + fsd, y = max(df(l, num_df, den_df)) + 0.02, color = "#6495ED", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = 'f Distribution', + ggtitle(label = 'f Distribution', subtitle = paste0("P(X > ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0(round((1 - pp) * 100, 2), "%"), - x = perc - fsd, y = max(stats::df(l, num_df, den_df)) + 0.04, color = "#6495ED", + annotate("text", label = paste0(round((1 - pp) * 100, 2), "%"), + x = perc - fsd, y = max(df(l, num_df, den_df)) + 0.04, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc + fsd, y = max(stats::df(l, num_df, den_df)) + 0.04, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc + fsd, y = max(df(l, num_df, den_df)) + 0.04, color = "#0000CD", size = 3) } @@ -259,7 +259,7 @@ vdist_f_prob <- function(perc = 2.35, num_df = 5, den_df = 32, type = c("lower", poly_data <- vdist_pol_f(lc[l1[i]], lc[l2[i]], num_df, den_df) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } @@ -271,15 +271,15 @@ vdist_f_prob <- function(perc = 2.35, num_df = 5, den_df = 32, type = c("lower", gplot <- gplot + - ggplot2::geom_vline(xintercept = perc[i], linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = perc[i], linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } gplot <- gplot + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = 0:max(l)) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = 0:max(l)) if (print_plot) { print(gplot) @@ -293,6 +293,5 @@ vdist_f_prob <- function(perc = 2.35, num_df = 5, den_df = 32, type = c("lower", vdist_pol_f <- function(l1, l2, num_df, den_df) { x <- c(l1, seq(l1, l2, 0.01), l2) y <- c(0, df(seq(l1, l2, 0.01), num_df, den_df), 0) - data <- data.frame(x = x, y = y) - return(data) + data.frame(x = x, y = y) } diff --git a/R/vdist-normal.R b/R/vdist-normal.R index aa02be2..6373fc6 100644 --- a/R/vdist-normal.R +++ b/R/vdist-normal.R @@ -43,16 +43,16 @@ vdist_normal_plot <- function(mean = 0, sd = 1, print_plot = TRUE) { l2 <- c(5, 3, 2, 6, 7) xm <- vdist_xmm(mean, sd) - plot_data <- data.frame(x = x, y = stats::dnorm(x, mean, sd)) + plot_data <- data.frame(x = x, y = dnorm(x, mean, sd)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y)) + - ggplot2::xlab('') + ggplot2::ylab('') + - ggplot2::ggtitle(label = "Normal Distribution", + ggplot(plot_data) + + geom_line(aes(x = x, y = y)) + + xlab('') + ylab('') + + ggtitle(label = "Normal Distribution", subtitle = paste("Mean:", mean, " Standard Deviation:", sd)) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) ll <- l[3:9] @@ -60,7 +60,7 @@ vdist_normal_plot <- function(mean = 0, sd = 1, print_plot = TRUE) { poly_data <- vdist_pol_cord(ll[l1[i]], ll[l2[i]], mean, sd) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), fill = col[i]) + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } if (print_plot) { @@ -90,21 +90,21 @@ vdist_normal_perc <- function(probs = 0.95, mean = 0, sd = 1, ln <- length(l) if (method == "lower") { - pp <- round(stats::qnorm(probs, mean, sd), 3) + pp <- round(qnorm(probs, mean, sd), 3) lc <- c(l[1], pp, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else if (method == "upper") { - pp <- round(stats::qnorm(probs, mean, sd, lower.tail = F), 3) + pp <- round(qnorm(probs, mean, sd, lower.tail = F), 3) lc <- c(l[1], pp, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) l2 <- c(2, 3) } else { alpha <- (1 - probs) / 2 - pp1 <- round(stats::qnorm(alpha, mean, sd), 3) - pp2 <- round(stats::qnorm(alpha, mean, sd, lower.tail = F), 3) + pp1 <- round(qnorm(alpha, mean, sd), 3) + pp2 <- round(qnorm(alpha, mean, sd, lower.tail = F), 3) pp <- c(pp1, pp2) lc <- c(l[1], pp1, pp2, l[ln]) col <- c("#6495ED", "#0000CD", "#6495ED") @@ -113,51 +113,51 @@ vdist_normal_perc <- function(probs = 0.95, mean = 0, sd = 1, } xm <- vdist_xmm(mean, sd) - plot_data <- data.frame(x = x, y = stats::dnorm(x, mean, sd)) + plot_data <- data.frame(x = x, y = dnorm(x, mean, sd)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y)) + - ggplot2::xlab(paste("Mean:", mean, " Standard Deviation:", sd)) + ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(aes(x = x, y = y)) + + xlab(paste("Mean:", mean, " Standard Deviation:", sd)) + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = "Normal Distribution", + ggtitle(label = "Normal Distribution", subtitle = paste0("P(X < ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = pp - sd, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = pp - sd, y = max(dnorm(x, mean, sd)) + 0.025, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0((1 - probs) * 100, "%"), - x = pp + sd, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#6495ED", + annotate("text", label = paste0((1 - probs) * 100, "%"), + x = pp + sd, y = max(dnorm(x, mean, sd)) + 0.025, color = "#6495ED", size = 3) } else if (method == "upper") { gplot <- gplot + - ggplot2::ggtitle(label = "Normal Distribution", + ggtitle(label = "Normal Distribution", subtitle = paste0("P(X > ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - probs) * 100, "%"), - x = pp - sd, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#6495ED", + annotate("text", label = paste0((1 - probs) * 100, "%"), + x = pp - sd, y = max(dnorm(x, mean, sd)) + 0.025, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = pp + sd, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = pp + sd, y = max(dnorm(x, mean, sd)) + 0.025, color = "#0000CD", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = "Normal Distribution", + ggtitle(label = "Normal Distribution", subtitle = paste0("P(", pp[1], " < X < ", pp[2], ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = mean, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = mean, y = max(dnorm(x, mean, sd)) + 0.025, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(alpha * 100, "%"), - x = pp[1] - sd, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#6495ED", + annotate("text", label = paste0(alpha * 100, "%"), + x = pp[1] - sd, y = max(dnorm(x, mean, sd)) + 0.025, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(alpha * 100, "%"), - x = pp[2] + sd, y = max(stats::dnorm(x, mean, sd)) + 0.025, color = "#6495ED", + annotate("text", label = paste0(alpha * 100, "%"), + x = pp[2] + sd, y = max(dnorm(x, mean, sd)) + 0.025, color = "#6495ED", size = 3) } @@ -165,7 +165,7 @@ vdist_normal_perc <- function(probs = 0.95, mean = 0, sd = 1, poly_data <- vdist_pol_cord(lc[l1[i]], lc[l2[i]], mean, sd) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), fill = col[i]) + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } pln <- length(pp) @@ -176,15 +176,15 @@ vdist_normal_perc <- function(probs = 0.95, mean = 0, sd = 1, gplot <- gplot + - ggplot2::geom_vline(xintercept = pp[i], linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = pp[i], linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } gplot <- gplot + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = l) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = l) if (print_plot) { print(gplot) @@ -226,20 +226,20 @@ vdist_normal_prob <- function(perc = 3, mean = 0, sd = 1, ln <- length(l) if (method == "lower") { - pp <- round(stats::pnorm(perc, mean, sd), 3) + pp <- round(pnorm(perc, mean, sd), 3) lc <- c(l[1], perc, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else if (method == "upper") { - pp <- round(stats::pnorm(perc, mean, sd, lower.tail = F), 3) + pp <- round(pnorm(perc, mean, sd, lower.tail = F), 3) lc <- c(l[1], perc, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) l2 <- c(2, 3) } else { - pp1 <- round(stats::pnorm(perc[1], mean, sd), 3) - pp2 <- round(stats::pnorm(perc[2], mean, sd, lower.tail = F), 3) + pp1 <- round(pnorm(perc[1], mean, sd), 3) + pp2 <- round(pnorm(perc[2], mean, sd, lower.tail = F), 3) pp <- c(pp1, pp2) lc <- c(l[1], perc[1], perc[2], l[ln]) col <- c("#6495ED", "#0000CD", "#6495ED") @@ -248,51 +248,51 @@ vdist_normal_prob <- function(perc = 3, mean = 0, sd = 1, } xm <- vdist_xmmp(mean, sd, el) - plot_data <- data.frame(x = x, y = stats::dnorm(x, mean, sd)) + plot_data <- data.frame(x = x, y = dnorm(x, mean, sd)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y)) + - ggplot2::xlab(paste("Mean:", mean, " Standard Deviation:", sd)) + ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(aes(x = x, y = y)) + + xlab(paste("Mean:", mean, " Standard Deviation:", sd)) + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = "Normal Distribution", + ggtitle(label = "Normal Distribution", subtitle = paste0("P(X < ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc - sd, y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc - sd, y = max(dnorm(x, mean, sd)) + 0.07, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0((1 - pp) * 100, "%"), - x = perc + sd, y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#6495ED", + annotate("text", label = paste0((1 - pp) * 100, "%"), + x = perc + sd, y = max(dnorm(x, mean, sd)) + 0.07, color = "#6495ED", size = 3) } else if (method == "upper") { gplot <- gplot + - ggplot2::ggtitle(label = "Normal Distribution", + ggtitle(label = "Normal Distribution", subtitle = paste0("P(X > ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - pp) * 100, "%"), - x = perc - sd, y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#6495ED", + annotate("text", label = paste0((1 - pp) * 100, "%"), + x = perc - sd, y = max(dnorm(x, mean, sd)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc + sd, y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc + sd, y = max(dnorm(x, mean, sd)) + 0.07, color = "#0000CD", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = "Normal Distribution", + ggtitle(label = "Normal Distribution", subtitle = paste0("P(", perc[1], " < X < ", perc[2], ") = ", (1 - (pp1 + pp2)) * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - (pp1 + pp2)) * 100, "%"), - x = mean(perc), y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#0000CD", + annotate("text", label = paste0((1 - (pp1 + pp2)) * 100, "%"), + x = mean(perc), y = max(dnorm(x, mean, sd)) + 0.07, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(pp[1] * 100, "%"), - x = perc[1] - sd, y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#6495ED", + annotate("text", label = paste0(pp[1] * 100, "%"), + x = perc[1] - sd, y = max(dnorm(x, mean, sd)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(pp[2] * 100, "%"), - x = perc[2] + sd, y = max(stats::dnorm(x, mean, sd)) + 0.07, color = "#6495ED", + annotate("text", label = paste0(pp[2] * 100, "%"), + x = perc[2] + sd, y = max(dnorm(x, mean, sd)) + 0.07, color = "#6495ED", size = 3) } @@ -300,7 +300,7 @@ vdist_normal_prob <- function(perc = 3, mean = 0, sd = 1, poly_data <- vdist_pol_cord(lc[l1[i]], lc[l2[i]], mean, sd) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), fill = col[i]) + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } pln <- length(pp) @@ -311,15 +311,15 @@ vdist_normal_prob <- function(perc = 3, mean = 0, sd = 1, gplot <- gplot + - ggplot2::geom_vline(xintercept = perc[i], linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = perc[i], linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } gplot <- gplot + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = l) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = l) if (print_plot) { print(gplot) @@ -332,30 +332,26 @@ vdist_normal_prob <- function(perc = 3, mean = 0, sd = 1, vdist_xax <- function(mean) { xl <- mean - 3 xu <- mean + 3 - x <- seq(xl, xu, 0.01) - return(x) + seq(xl, xu, 0.01) } vdist_seql <- function(mean, sd) { lmin <- mean - (5 * sd) lmax <- mean + (5 * sd) - l <- seq(lmin, lmax, sd) - return(l) + seq(lmin, lmax, sd) } vdist_pol_cord <- function(l1, l2, mean, sd) { x <- c(l1, seq(l1, l2, 0.01), l2) - y <- c(0, stats::dnorm(seq(l1, l2, 0.01), mean, sd), 0) - data <- data.frame(x = x, y = y) - return(data) + y <- c(0, dnorm(seq(l1, l2, 0.01), mean, sd), 0) + data.frame(x = x, y = y) } vdist_xaxp <- function(mean, el) { xl <- mean - el xu <- mean + el - x <- seq(xl, xu, 0.01) - return(x) + seq(xl, xu, 0.01) } @@ -368,8 +364,7 @@ vdist_seqlp <- function(mean, sd, el) { lmax <- mean + (4 * sd) } - l <- seq(lmin, lmax, sd) - return(l) + seq(lmin, lmax, sd) } vdist_xmmp <- function(mean, sd, el) { @@ -381,6 +376,5 @@ vdist_xmmp <- function(mean, sd, el) { xmax <- mean + (4 * sd) } - out <- c(xmin, xmax) - return(out) + c(xmin, xmax) } diff --git a/R/vdist-t.R b/R/vdist-t.R index 709a282..3007e5b 100644 --- a/R/vdist-t.R +++ b/R/vdist-t.R @@ -42,21 +42,21 @@ vdist_t_plot <- function(df = 3, print_plot = TRUE) { df <- as.integer(df) x <- seq(-4, 4, 0.01) - plot_data <- data.frame(x = x, y = stats::dt(x, df)) + plot_data <- data.frame(x = x, y = dt(x, df)) poly_data <- data.frame(y = c(-4, seq(-4, 4, 0.01), 4), - z = c(0, stats::dt(seq(-4, 4, 0.01), df), 0)) + z = c(0, dt(seq(-4, 4, 0.01), df), 0)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y), color = 'blue') + - ggplot2::ggtitle(label = 't Distribution', subtitle = paste("df =", df)) + - ggplot2::xlab('') + ggplot2::ylab('') + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = y, y = z), + ggplot(plot_data) + + geom_line(aes(x = x, y = y), color = 'blue') + + ggtitle(label = 't Distribution', subtitle = paste("df =", df)) + + xlab('') + ylab('') + + geom_polygon(data = poly_data, mapping = aes(x = y, y = z), fill = '#4682B4') + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = -4:4) + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = -4:4) + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (print_plot) { print(gplot) @@ -83,21 +83,21 @@ vdist_t_perc <- function(probs = 0.95, df = 4, ln <- length(l) if (method == "lower") { - pp <- round(stats::qt(probs, df), 3) + pp <- round(qt(probs, df), 3) lc <- c(l[1], pp, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else if (method == "upper") { - pp <- round(stats::qt(probs, df, lower.tail = F), 3) + pp <- round(qt(probs, df, lower.tail = F), 3) lc <- c(l[1], pp, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) l2 <- c(2, 3) } else { alpha <- (1 - probs) / 2 - pp1 <- round(stats::qt(alpha, df), 3) - pp2 <- round(stats::qt(alpha, df, lower.tail = F), 3) + pp1 <- round(qt(alpha, df), 3) + pp2 <- round(qt(alpha, df, lower.tail = F), 3) pp <- c(pp1, pp2) lc <- c(l[1], pp1, pp2, l[ln]) col <- c("#6495ED", "#0000CD", "#6495ED") @@ -105,51 +105,51 @@ vdist_t_perc <- function(probs = 0.95, df = 4, l2 <- c(2, 3, 4) } - plot_data <- data.frame(x = l, y = stats::dt(l, df)) + plot_data <- data.frame(x = l, y = dt(l, df)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y), color = 'blue') + - ggplot2::xlab(paste("df =", df)) + ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + ggplot(plot_data) + + geom_line(aes(x = x, y = y), color = 'blue') + + xlab(paste("df =", df)) + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) if (method == "lower") { gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(X < ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = pp - 0.3, y = max(stats::dt(l, df)) + 0.025, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = pp - 0.3, y = max(dt(l, df)) + 0.025, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0((1 - probs) * 100, "%"), - x = pp + 0.3, y = max(stats::dt(l, df)) + 0.025, color = "#6495ED", + annotate("text", label = paste0((1 - probs) * 100, "%"), + x = pp + 0.3, y = max(dt(l, df)) + 0.025, color = "#6495ED", size = 3) } else if (method == "upper") { gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(X > ", pp, ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - probs) * 100, "%"), - x = pp - 0.3, y = max(stats::dt(l, df)) + 0.025, color = "#6495ED", + annotate("text", label = paste0((1 - probs) * 100, "%"), + x = pp - 0.3, y = max(dt(l, df)) + 0.025, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = pp + 0.3, y = max(stats::dt(l, df)) + 0.025, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = pp + 0.3, y = max(dt(l, df)) + 0.025, color = "#0000CD", size = 3) } else { gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(", pp[1], " < X < ", pp[2], ") = ", probs * 100, "%")) + - ggplot2::annotate("text", label = paste0(probs * 100, "%"), - x = mean(l), y = max(stats::dt(l, df)) + 0.025, color = "#0000CD", + annotate("text", label = paste0(probs * 100, "%"), + x = mean(l), y = max(dt(l, df)) + 0.025, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(alpha * 100, "%"), - x = pp[1] - 0.3, y = max(stats::dt(l, df)) + 0.025, color = "#6495ED", + annotate("text", label = paste0(alpha * 100, "%"), + x = pp[1] - 0.3, y = max(dt(l, df)) + 0.025, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(alpha * 100, "%"), - x = pp[2] + 0.3, y = max(stats::dt(l, df)) + 0.025, color = "#6495ED", + annotate("text", label = paste0(alpha * 100, "%"), + x = pp[2] + 0.3, y = max(dt(l, df)) + 0.025, color = "#6495ED", size = 3) } @@ -157,7 +157,7 @@ vdist_t_perc <- function(probs = 0.95, df = 4, poly_data <- vdist_pol_t(lc[l1[i]], lc[l2[i]], df) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), fill = col[i]) + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } pln <- length(pp) @@ -168,15 +168,15 @@ vdist_t_perc <- function(probs = 0.95, df = 4, gplot <- gplot + - ggplot2::geom_vline(xintercept = pp[i], linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = pp[i], linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } gplot <- gplot + - ggplot2::scale_y_continuous(breaks = NULL) + - ggplot2::scale_x_continuous(breaks = -5:5) + scale_y_continuous(breaks = NULL) + + scale_x_continuous(breaks = -5:5) if (print_plot) { print(gplot) @@ -208,13 +208,13 @@ vdist_t_prob <- function(perc = 1.6, df = 7, ln <- length(l) if (method == "lower") { - pp <- round(stats::pt(perc, df), 3) + pp <- round(pt(perc, df), 3) lc <- c(l[1], perc, l[ln]) col <- c("#0000CD", "#6495ED") l1 <- c(1, 2) l2 <- c(2, 3) } else if (method == "upper") { - pp <- round(stats::pt(perc, df, lower.tail = F), 3) + pp <- round(pt(perc, df, lower.tail = F), 3) lc <- c(l[1], perc, l[ln]) col <- c("#6495ED", "#0000CD") l1 <- c(1, 2) @@ -224,8 +224,8 @@ vdist_t_prob <- function(perc = 1.6, df = 7, perc <- -perc } - pp1 <- round(stats::pt(-perc, df), 3) - pp2 <- round(stats::pt(perc, df, lower.tail = F), 3) + pp1 <- round(pt(-perc, df), 3) + pp2 <- round(pt(perc, df, lower.tail = F), 3) pp <- c(pp1, pp2) lc <- c(l[1], -perc, perc, l[ln]) col <- c("#6495ED", "#0000CD", "#6495ED") @@ -236,8 +236,8 @@ vdist_t_prob <- function(perc = 1.6, df = 7, perc <- -perc } - pp1 <- round(stats::pt(-perc, df), 3) - pp2 <- round(stats::pt(perc, df, lower.tail = F), 3) + pp1 <- round(pt(-perc, df), 3) + pp2 <- round(pt(perc, df, lower.tail = F), 3) pp <- c(pp1, pp2) lc <- c(l[1], -perc, perc, l[ln]) col <- c("#0000CD", "#6495ED", "#0000CD") @@ -245,22 +245,22 @@ vdist_t_prob <- function(perc = 1.6, df = 7, l2 <- c(2, 3, 4) } - plot_data <- data.frame(x = l, y = stats::dt(l, df)) + plot_data <- data.frame(x = l, y = dt(l, df)) gplot <- - ggplot2::ggplot(plot_data) + - ggplot2::geom_line(ggplot2::aes(x = x, y = y), color = 'blue') + - ggplot2::xlab(paste("df =", df)) + ggplot2::ylab('') + - ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5), - plot.subtitle = ggplot2::element_text(hjust = 0.5)) + - ggplot2::scale_x_continuous(breaks = min(l):max(l)) + - ggplot2::scale_y_continuous(breaks = NULL) + ggplot(plot_data) + + geom_line(aes(x = x, y = y), color = 'blue') + + xlab(paste("df =", df)) + ylab('') + + theme(plot.title = element_text(hjust = 0.5), + plot.subtitle = element_text(hjust = 0.5)) + + scale_x_continuous(breaks = min(l):max(l)) + + scale_y_continuous(breaks = NULL) for (i in seq_len(length(l1))) { poly_data <- vdist_pol_t(lc[l1[i]], lc[l2[i]], df) gplot <- gplot + - ggplot2::geom_polygon(data = poly_data, mapping = ggplot2::aes(x = x, y = y), fill = col[i]) + geom_polygon(data = poly_data, mapping = aes(x = x, y = y), fill = col[i]) } @@ -270,16 +270,16 @@ vdist_t_prob <- function(perc = 1.6, df = 7, gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(X < ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc - 1, y = max(stats::dt(l, df)) + 0.07, color = "#0000CD", + annotate("text", label = paste0(pp * 100, "%"), + x = perc - 1, y = max(dt(l, df)) + 0.07, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0((1 - pp) * 100, "%"), - x = perc + 1, y = max(stats::dt(l, df)) + 0.07, color = "#6495ED", + annotate("text", label = paste0((1 - pp) * 100, "%"), + x = perc + 1, y = max(dt(l, df)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::geom_vline(xintercept = perc, linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = perc, linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } else if (method == "upper") { @@ -288,16 +288,16 @@ vdist_t_prob <- function(perc = 1.6, df = 7, gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(X > ", perc, ") = ", pp * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - pp) * 100, "%"), - x = perc - 1, y = max(stats::dt(l, df)) + 0.07, color = "#0000CD", + annotate("text", label = paste0((1 - pp) * 100, "%"), + x = perc - 1, y = max(dt(l, df)) + 0.07, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(pp * 100, "%"), - x = perc + 1, y = max(stats::dt(l, df)) + 0.07, color = "#6495ED", + annotate("text", label = paste0(pp * 100, "%"), + x = perc + 1, y = max(dt(l, df)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::geom_vline(xintercept = perc, linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x, y = y), + geom_vline(xintercept = perc, linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x, y = y), shape = 4, color = 'red', size = 3) } else if (method == "interval") { @@ -306,21 +306,21 @@ vdist_t_prob <- function(perc = 1.6, df = 7, gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(", -perc, " < X < ", perc, ") = ", (1 - (pp1 + pp2)) * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - (pp1 + pp2)) * 100, "%"), - x = 0, y = max(stats::dt(l, df)) + 0.07, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(pp[1] * 100, "%"), - x = perc + 1, y = max(stats::dt(l, df)) + 0.07, color = "#6495ED", + annotate("text", label = paste0((1 - (pp1 + pp2)) * 100, "%"), + x = 0, y = max(dt(l, df)) + 0.07, color = "#0000CD", size = 3) + + annotate("text", label = paste0(pp[1] * 100, "%"), + x = perc + 1, y = max(dt(l, df)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(pp[2] * 100, "%"), - x = -perc - 1, y = max(stats::dt(l, df)) + 0.07, color = "#6495ED", + annotate("text", label = paste0(pp[2] * 100, "%"), + x = -perc - 1, y = max(dt(l, df)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::geom_vline(xintercept = perc, linetype = 2, size = 1) + - ggplot2::geom_vline(xintercept = -perc, linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x1, y = y), + geom_vline(xintercept = perc, linetype = 2, size = 1) + + geom_vline(xintercept = -perc, linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x1, y = y), shape = 4, color = 'red', size = 3) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x2, y = y), + geom_point(data = point_data, mapping = aes(x = x2, y = y), shape = 4, color = 'red', size = 3) } else { @@ -328,21 +328,21 @@ vdist_t_prob <- function(perc = 1.6, df = 7, gplot <- gplot + - ggplot2::ggtitle(label = "t Distribution", + ggtitle(label = "t Distribution", subtitle = paste0("P(|X| > ", perc, ") = ", (pp1 + pp2) * 100, "%")) + - ggplot2::annotate("text", label = paste0((1 - (pp1 + pp2)) * 100, "%"), - x = 0, y = max(stats::dt(l, df)) + 0.07, color = "#0000CD", size = 3) + - ggplot2::annotate("text", label = paste0(pp[1] * 100, "%"), - x = perc + 1, y = max(stats::dt(l, df)) + 0.07, color = "#6495ED", + annotate("text", label = paste0((1 - (pp1 + pp2)) * 100, "%"), + x = 0, y = max(dt(l, df)) + 0.07, color = "#0000CD", size = 3) + + annotate("text", label = paste0(pp[1] * 100, "%"), + x = perc + 1, y = max(dt(l, df)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::annotate("text", label = paste0(pp[2] * 100, "%"), - x = -perc - 1, y = max(stats::dt(l, df)) + 0.07, color = "#6495ED", + annotate("text", label = paste0(pp[2] * 100, "%"), + x = -perc - 1, y = max(dt(l, df)) + 0.07, color = "#6495ED", size = 3) + - ggplot2::geom_vline(xintercept = perc, linetype = 2, size = 1) + - ggplot2::geom_vline(xintercept = -perc, linetype = 2, size = 1) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x1, y = y), + geom_vline(xintercept = perc, linetype = 2, size = 1) + + geom_vline(xintercept = -perc, linetype = 2, size = 1) + + geom_point(data = point_data, mapping = aes(x = x1, y = y), shape = 4, color = 'red', size = 3) + - ggplot2::geom_point(data = point_data, mapping = ggplot2::aes(x = x2, y = y), + geom_point(data = point_data, mapping = aes(x = x2, y = y), shape = 4, color = 'red', size = 3) } @@ -357,7 +357,6 @@ vdist_t_prob <- function(perc = 1.6, df = 7, vdist_pol_t <- function(l1, l2, df) { x <- c(l1, seq(l1, l2, 0.01), l2) - y <- c(0, stats::dt(seq(l1, l2, 0.01), df), 0) - data <- data.frame(x = x, y = y) - return(data) + y <- c(0, dt(seq(l1, l2, 0.01), df), 0) + data.frame(x = x, y = y) } diff --git a/R/vdist-utils.R b/R/vdist-utils.R index 54a7522..6531732 100644 --- a/R/vdist-utils.R +++ b/R/vdist-utils.R @@ -1,7 +1,8 @@ -#' @importFrom utils packageVersion menu install.packages +#' @import utils +#' @import ggplot2 check_suggests <- function(pkg) { - pkg_flag <- tryCatch(utils::packageVersion(pkg), error = function(e) NA) + pkg_flag <- tryCatch(packageVersion(pkg), error = function(e) NA) if (is.na(pkg_flag)) { @@ -9,8 +10,8 @@ check_suggests <- function(pkg) { if (interactive()) { message(msg, "\nWould you like to install it?") - if (utils::menu(c("Yes", "No")) == 1) { - utils::install.packages(pkg) + if (menu(c("Yes", "No")) == 1) { + install.packages(pkg) } else { stop(msg, call. = FALSE) } diff --git a/R/vistributions.R b/R/vistributions.R index 633a791..6ca6f7e 100644 --- a/R/vistributions.R +++ b/R/vistributions.R @@ -8,7 +8,7 @@ NULL ## quiets concerns of R CMD check re: the .'s that appear in pipelines if (getRversion() >= "2.15.1") { - utils::globalVariables(c( + globalVariables(c( ".", "df", "chi", "x", "y", "z", "x1", "x2" )) } diff --git a/R/zzz.R b/R/zzz.R index d148d35..ae9f404 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,16 +1,17 @@ -#' @importFrom magrittr %>% +#' @import magrittr +#' @import stats .onAttach <- function(...) { - if (!interactive() || stats::runif(1) > 0.1) return() + if (!interactive() || runif(1) > 0.1) return() - pkgs <- utils::available.packages() + pkgs <- available.packages() cran_version <- pkgs %>% - magrittr::extract("vistributions", "Version") %>% + extract("vistributions", "Version") %>% package_version() - local_version <- utils::packageVersion("vistributions") + local_version <- packageVersion("vistributions") behind_cran <- cran_version > local_version tips <- c( @@ -26,8 +27,8 @@ if (behind_cran) { msg <- "A new version of vistributions is available with bug fixes and new features." packageStartupMessage(msg, "\nWould you like to install it?") - if (utils::menu(c("Yes", "No")) == 1) { - utils::update.packages("vistributions") + if (menu(c("Yes", "No")) == 1) { + update.packages("vistributions") } } else { packageStartupMessage(paste(strwrap(tip), collapse = "\n")) diff --git a/README.Rmd b/README.Rmd index 946a131..082d154 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,7 @@ knitr::opts_chunk$set( [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/vistributions)](https://cran.r-project.org/package=vistributions) [![cran checks](https://cranchecks.info/badges/summary/vistributions)](https://cran.r-project.org/web/checks/check_results_vistributions.html) [![R build status](https://github.com/rsquaredacademy/vistributions/workflows/R-CMD-check/badge.svg)](https://github.com/rsquaredacademy/vistributions/actions) -[![Coverage Status](https://img.shields.io/codecov/c/github/rsquaredacademy/vistributions/master.svg)](https://codecov.io/github/rsquaredacademy/vistributions?branch=master) [![status](https://tinyverse.netlify.com/badge/vistributions)](https://CRAN.R-project.org/package=vistributions) [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) [![](https://cranlogs.r-pkg.org/badges/grand-total/vistributions)](https://cran.r-project.org/package=vistributions) +[![Coverage Status](https://img.shields.io/codecov/c/github/rsquaredacademy/vistributions/master.svg)](https://codecov.io/github/rsquaredacademy/vistributions?branch=master) [![status](https://tinyverse.netlify.com/badge/vistributions)](https://CRAN.R-project.org/package=vistributions) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![](https://cranlogs.r-pkg.org/badges/grand-total/vistributions)](https://cran.r-project.org/package=vistributions) ## Installation @@ -35,7 +35,7 @@ devtools::install_github("rsquaredacademy/vistributions") ## Articles -- [Explore Distributions](https://vistributions.rsquaredacademy.com/articles/introduction_to_vistributions.html) +- [Explore Distributions](https://vistributions.rsquaredacademy.com/articles/introduction-to-vistributions.html) ## Usage @@ -61,7 +61,3 @@ vdist_normal_prob(c(-1.74, 1.83), type = 'both') If you encounter a bug, please file a minimal reproducible example using [reprex](https://reprex.tidyverse.org/index.html) on github. For questions and clarifications, use [StackOverflow](https://stackoverflow.com/). - -## Community Guidelines - -Please note that the 'vistributions' project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms. diff --git a/README.md b/README.md index 491a81d..fc0b87e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ status](https://github.com/rsquaredacademy/vistributions/workflows/R-CMD-check/b [![Coverage Status](https://img.shields.io/codecov/c/github/rsquaredacademy/vistributions/master.svg)](https://codecov.io/github/rsquaredacademy/vistributions?branch=master) [![status](https://tinyverse.netlify.com/badge/vistributions)](https://CRAN.R-project.org/package=vistributions) -[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) +[![Lifecycle: +stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![](https://cranlogs.r-pkg.org/badges/grand-total/vistributions)](https://cran.r-project.org/package=vistributions) @@ -32,8 +33,8 @@ devtools::install_github("rsquaredacademy/vistributions") ## Articles - - [Explore - Distributions](https://vistributions.rsquaredacademy.com/articles/introduction_to_vistributions.html) +- [Explore + Distributions](https://vistributions.rsquaredacademy.com/articles/introduction-to-vistributions.html) ## Usage @@ -47,7 +48,6 @@ vdist_normal_plot() ``` r - # visualize quantiles out of given probability vdist_normal_perc(0.95, mean = 2, sd = 1.36, type = 'both') ``` @@ -55,7 +55,6 @@ vdist_normal_perc(0.95, mean = 2, sd = 1.36, type = 'both') ``` r - # visualize probability from a given quantile vdist_normal_prob(c(-1.74, 1.83), type = 'both') ``` @@ -68,9 +67,3 @@ If you encounter a bug, please file a minimal reproducible example using [reprex](https://reprex.tidyverse.org/index.html) on github. For questions and clarifications, use [StackOverflow](https://stackoverflow.com/). - -## Community Guidelines - -Please note that the ‘vistributions’ project is released with a -[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to -this project, you agree to abide by its terms. diff --git a/_pkgdown.yml b/_pkgdown.yml index a07ac6b..5bde5f8 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -7,6 +7,7 @@ authors: templates: params: bootswatch: cosmo + ganalytics: UA-57270671-33 docsearch: api_key: index_name: vistributions diff --git a/cran-comments.md b/cran-comments.md index 4b837cb..9325a47 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,6 @@ ## Test environments -* local Windows 10, R 3.5.2 -* ubuntu 14.04 (on travis-ci), R 3.4.4, R 3.5.2, R devel +* local Windows 10 install, R 4.0.4 +* ubuntu 14.04 (on GitHub Actions), R 4.1.0, R-devel * win-builder (devel and release) ## R CMD check results