diff --git a/R/plot_grade_range.R b/R/plot_grade_range.R index 50eeeb5..42ce917 100644 --- a/R/plot_grade_range.R +++ b/R/plot_grade_range.R @@ -5,6 +5,7 @@ #' @param remaining_ects the number of ECTS credits remaining to complete #' @param max_passing_grade the best possible grade #' @param min_passing_grade the worst possible grade +#' @param caption_width text width for the caption. default 150 #' #' @return a ggplot2 object #' @export @@ -25,7 +26,8 @@ #' plot_grade_range(30, ., 90, max_passing_grade = 4, min_passing_grade = 1) #' plot_grade_range <- function(completed_ects, current_grade, remaining_ects, - max_passing_grade = 1, min_passing_grade = 5) { + max_passing_grade = 1, min_passing_grade = 5, + caption_width = 150) { program_ects <- completed_ects + remaining_ects grades <- calculate_grade_range( @@ -48,7 +50,7 @@ plot_grade_range <- function(completed_ects, current_grade, remaining_ects, caption_text <- glue::glue("The shaded region represents the range of all possible grade averages that can be achieved based on three factors: 1) the current grade average or GPA, 2) the number of ECTS credits already completed, 3) and the amount of remaining ECTS to complete.\n\nThe red line indicates the worst possible scenario i.e. obtaining {min_passing_grade}s in all classes while the green line indicates the best possible scenario i.e. obtaining {max_passing_grade}s in all classes. The blue dashed line represents the highest passing grade, a 1.0 and a 4.0 on the common German and American scales, respectively.") %>% - stringr::str_wrap(width = 150) + stringr::str_wrap(width = caption_width) ggplot2::ggplot(data = plt_data) + diff --git a/README.Rmd b/README.Rmd index b4dfce4..5184b77 100644 --- a/README.Rmd +++ b/README.Rmd @@ -59,7 +59,8 @@ plot_grade_range( current_grade = 1.5, remaining_ects = 60, max_passing_grade = 1, - min_passing_grade = 5 + min_passing_grade = 5, + caption_width = 120 ) ``` diff --git a/README.md b/README.md index bf8c933..25fe182 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ plot_grade_range( current_grade = 1.5, remaining_ects = 60, max_passing_grade = 1, - min_passing_grade = 5 + min_passing_grade = 5, + caption_width = 120 ) ``` diff --git a/man/figures/README-unnamed-chunk-2-1.png b/man/figures/README-unnamed-chunk-2-1.png index 96059f2..1161d77 100644 Binary files a/man/figures/README-unnamed-chunk-2-1.png and b/man/figures/README-unnamed-chunk-2-1.png differ diff --git a/man/plot_grade_range.Rd b/man/plot_grade_range.Rd index 5e3198f..bf8c957 100644 --- a/man/plot_grade_range.Rd +++ b/man/plot_grade_range.Rd @@ -9,7 +9,8 @@ plot_grade_range( current_grade, remaining_ects, max_passing_grade = 1, - min_passing_grade = 5 + min_passing_grade = 5, + caption_width = 150 ) } \arguments{ @@ -22,6 +23,8 @@ plot_grade_range( \item{max_passing_grade}{the best possible grade} \item{min_passing_grade}{the worst possible grade} + +\item{caption_width}{text width for the caption. default 150} } \value{ a ggplot2 object