Skip to content

Commit

Permalink
Add new arg to plot fxn and rebuild readme
Browse files Browse the repository at this point in the history
  • Loading branch information
NeuroShepherd committed Jul 8, 2024
1 parent 62bec88 commit 7e58d22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions R/plot_grade_range.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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) +
Expand Down
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
```

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
```

Expand Down
Binary file modified man/figures/README-unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion man/plot_grade_range.Rd

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

0 comments on commit 7e58d22

Please sign in to comment.