Navigation Menu

Skip to content

Commit

Permalink
Cleaned up warnings & notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Auburngrads committed Jul 13, 2016
1 parent b83e594 commit a768f0d
Show file tree
Hide file tree
Showing 25 changed files with 422 additions and 46 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Expand Up @@ -8,5 +8,4 @@ Maintainer: <auburngrads@live.com>
Description: An implementation of Crawford's and Wright's learning curve production functions. It provides unit and cumulative block estimates for time (or cost) of units along with an aggregate learning curve. It also provides delta and error functions and some basic learning curve plotting functions.
License: GPL-2
RoxygenNote: 5.0.1
Imports:
ggplot2
Imports: ggplot2
23 changes: 22 additions & 1 deletion NAMESPACE
@@ -1,3 +1,24 @@
# Generated by roxygen2: do not edit by hand

export(wright)
export(agg_curve)
export(ca_block)
export(ca_unit)
export(cum_error)
export(delta)
export(lc_rate)
export(lc_rate_est)
export(natural_slope)
export(natural_slope_est)
export(plot_block_summary)
export(plot_delta)
export(plot_unit_curve)
export(unit_block_summary)
export(unit_cum_appx)
export(unit_cum_exact)
export(unit_curve)
export(unit_midpoint)
importFrom(ggplot2,aes)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_text)
importFrom(ggplot2,ggplot)
1 change: 1 addition & 0 deletions R/aggregate_model.R
Expand Up @@ -5,6 +5,7 @@
#' @param t vector of hours (or costs) for the first unit from departments 1 through m
#' @param n total units to be produced across all departments
#' @param r vector of historical learning rates for departments 1 through m
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down
2 changes: 2 additions & 0 deletions R/cumulative_avg_models.R
Expand Up @@ -6,6 +6,7 @@
#' @param n nth unit you wish to predict the time (or cost) for
#' @param m mth unit for which you have time (or cost) information (default is m = 1)
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down Expand Up @@ -47,6 +48,7 @@ ca_unit <- function(t, n, r, m = 1, na.rm = FALSE){
#' @param n last unit of the production block of concern
#' @param m first unit of the production block of concern (default: m = 1)
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down
39 changes: 24 additions & 15 deletions R/plot_functions.R
Expand Up @@ -8,6 +8,12 @@
#' @param r learning curve rate
#' @param model choose between the Crawford ("u") or Wright ("ca") models or plot both models with "both"
#' @param level plot the learning curve at the unit ("u") or cumulative ("c") level
#'
#' @importFrom ggplot2 ggplot
#' @importFrom ggplot2 geom_line
#' @importFrom ggplot2 geom_point
#' @importFrom ggplot2 geom_text
#' @importFrom ggplot2 aes
#'
#' @export

Expand All @@ -23,10 +29,10 @@ plot_unit_curve <- function(t, m, n, r, model = "u", level = "u"){
cumulative.value = cumsum(unit_curve(t = t, m, n = m:n, r = r)))

if(level == "u") {
ggplot2::ggplot(data = df, aes(x = x, y = value)) +
ggplot2::ggplot(data = df, ggplot2::aes(x = df$x, y = df$value)) +
geom_line()
} else {
ggplot2::ggplot(data = df, aes(x = x, y = cumulative.value)) +
ggplot2::ggplot(data = df, ggplot2::aes(x = df$x, y = df$cumulative.value)) +
geom_line()
}

Expand All @@ -37,10 +43,10 @@ plot_unit_curve <- function(t, m, n, r, model = "u", level = "u"){
cumulative.value = cumsum(ca_unit(t = t, m = m, n = m:n, r = r)))

if(level == "u") {
ggplot2::ggplot(data = df, aes(x = x, y = value)) +
ggplot2::ggplot(data = df, ggplot2::aes(x = df$x, y = df$value)) +
geom_line()
} else {
ggplot2::ggplot(data = df, aes(x = x, y = cumulative.value)) +
ggplot2::ggplot(data = df, ggplot2::aes(x = df$x, y = df$cumulative.value)) +
geom_line()
}

Expand All @@ -58,10 +64,10 @@ plot_unit_curve <- function(t, m, n, r, model = "u", level = "u"){
df <- rbind(df1, df2)

if(level == "u") {
ggplot2::ggplot(data = df, aes(x = x, y = value, color = model)) +
ggplot2::ggplot(data = df, ggplot2::aes(x = df$x, y = df$value, color = df$model)) +
geom_line()
} else{
ggplot2::ggplot(data = df, aes(x = x, y = cumulative.value, color = model)) +
} else {
ggplot2::ggplot(data = df, ggplot2::aes(x = df$x, y = df$cumulative.value, color = df$model)) +
geom_line()
}
}
Expand All @@ -82,16 +88,17 @@ plot_unit_curve <- function(t, m, n, r, model = "u", level = "u"){

plot_block_summary <- function(t, m, n, r){

df <- data.frame(x = m:n, value = unit_curve(t = t, m = m, n = m:n, r = r))
df <- data.frame(x = m:n,
value = unit_curve(t = t, m = m, n = m:n, r = r))

midpoint <- data.frame(x = unit_block_summary(t, m, n, r)[[3]],
value = unit_block_summary(t, m, n, r)[[4]],
label = paste0("[", round(unit_block_summary(t, m, n, r)[[3]]), ", ", round(unit_block_summary(t, m, n, r)[[4]]), "]"))

ggplot2::ggplot(df, aes(x = x, y = value)) +
ggplot2::ggplot(data = df, aes(x = df$x, y = df$value)) +
geom_line() +
geom_point(data = midpoint, aes(x = x, y = value)) +
geom_text(data = midpoint, aes(x = x, y = value, label = label),
geom_point(data = midpoint, aes(x = midpoint$x, y = midpoint$value)) +
geom_text(data = midpoint, aes(x = midpoint$x, y = midpoint$value, label = midpoint$label),
hjust = 0, vjust = 0)
}

Expand All @@ -115,19 +122,21 @@ plot_delta <- function(t, m, n, r, level = "u"){
}

if(level == "u") {
df <- data.frame(x = m:n, y = delta(t = t, m = m, n = n, r = r, level = "u"))
df <- data.frame(x = m:n,
y = delta(t = t, m = m, n = n, r = r, level = "u"))

y <- ggplot2::ggplot(df, aes(x = x, y = y)) +
y <- ggplot2::ggplot(data = df, aes(x = df$x, y = df$y)) +
geom_line()

if(n < 100) y <- y + geom_point(size = .5)

}

if(level == "c") {
df <- data.frame(x = m:n, y = delta(t = t, m = m, n = n, r = r, level = "c"))
df <- data.frame(x = m:n,
y = delta(t = t, m = m, n = n, r = r, level = "c"))

y <- ggplot2::ggplot(df, aes(x = x, y = y)) +
y <- ggplot2::ggplot(data = df, aes(x = df$x, y = df$y)) +
geom_line()

if(n < 100) y <- y + geom_point(size = .5)
Expand Down
2 changes: 2 additions & 0 deletions R/slope_rate_models.R
Expand Up @@ -3,6 +3,7 @@
#' @description Computes the natural slope rate for given learning rates
#'
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand All @@ -29,6 +30,7 @@ natural_slope <- function(r, na.rm = FALSE){
#' @description Computes the learning rate for given natural slopes
#'
#' @param b natural slope
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down
18 changes: 7 additions & 11 deletions R/unit_models.R
Expand Up @@ -6,6 +6,7 @@
#' @param n nth unit you wish to predict the time (or cost) for
#' @param m mth unit of production (default set to 1st production unit)
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down Expand Up @@ -43,9 +44,10 @@ unit_curve <- function(t, n, r, m = 1, na.rm = FALSE){
#' @description Provides the exact cumulative time or cost required for units m through n (inclusive) using the Crawford unit model
#'
#' @param t time (or cost) required for the mth unit of production
#' @param nth unit you wish to predict the cumulative time (or cost) to
#' @param n The unit you wish to predict the cumulative time (or cost) to
#' @param m mth unit of production (default set to 1st production unit)
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down Expand Up @@ -91,9 +93,10 @@ unit_cum_exact <- function(t, n, r, m = 1, na.rm = FALSE){
#' @description Provides the approximate cumulative time or cost required for units m through n (inclusive) using the Crawford unit model. Provides nearly the exact output as unit_cum_exact(), usually only off by 1-2 units but reduces computational time drastically if trying to calculate cumulative hours (costs) for over a million units.
#'
#' @param t time (or cost) required for the mth unit of production
#' @param nth unit you wish to predict the cumulative time (or cost) to
#' @param n The unit you wish to predict the cumulative time (or cost) to
#' @param m mth unit of production (default set to 1st production unit)
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down Expand Up @@ -141,6 +144,7 @@ unit_cum_appx <- function(t, n, r, m = 1, na.rm = FALSE){
#' @param m lower bound unit of production
#' @param n upper bound unit of production
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down Expand Up @@ -187,6 +191,7 @@ unit_midpoint <- function(m, n, r, na.rm = FALSE){
#' @param m lower bound unit of production block
#' @param n upper bound unit of production block
#' @param r learning curve rate
#' @param na.rm Should \code{NA} values be removed?
#'
#' @export

Expand Down Expand Up @@ -232,12 +237,3 @@ unit_block_summary <- function(t, m, n, r, na.rm = FALSE){
return(y)

}









21 changes: 21 additions & 0 deletions man/agg_curve.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/ca_block.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/ca_unit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/cum_error.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/delta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/lc_rate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/lc_rate_est.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a768f0d

Please sign in to comment.