Skip to content

Commit 10416d3

Browse files
authored
Merge pull request #4 from globeandmail/write_plot_fix
Fixes issues with write_plot and initialize_startr
2 parents 0366b30 + f0b9be0 commit 10416d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+299
-553
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: upstartr
22
Type: Package
33
Title: Utilities Powering the Globe and Mail's Data Journalism Template
4-
Version: 0.1.0
4+
Version: 0.1.1
55
Authors@R:
66
c(person(given = "Tom",
77
family = "Cardoso",

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 0.1.1
2+
====================
3+
4+
Small bug fixes:
5+
- Adds an extra newline to the `initialize_startr()` log messages so that it stays on its own line.
6+
- Fixes an issue with `write_plot()` where the `format` parameter was inadvertently being passed to `ggsave()`, which would then throw an error.
7+
18
Version 0.1.0
29
====================
310

R/init.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ initialize_startr <- function(
9191
root.dir = here::here()
9292
)
9393

94-
cat(crayon::green(glue::glue('{bquote("\u2713")} Your startr project \'{crayon::bold(title)}\' has been initialized!\n')))
94+
cat(crayon::green(glue::glue('{bquote("\u2713")} Your startr project {crayon::bold(title)} has been initialized!\n\n')))
9595
}

R/write.R

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,22 @@ write_excel <- function(variable, output_dir = dir_data_out(), should_timestamp_
3333
#' variable name as the filename.
3434
#'
3535
#' @param variable A tibble or dataframe object.
36+
#' @param format The desired format for the plot, be it 'png', 'pdf', etc. Accepts formats
37+
#' you'd pass to \code{ggplot2::\link[ggplot2:ggsave]{ggsave}}'s 'device' parameter.
3638
#' @param output_dir The directory to save the plot out to.
3739
#' @param ... Other settings to pass to ggsave, such as format, width, height or dpi.
3840
#'
3941
#' @return No return value, called for side effects
4042
#'
4143
#' @export
42-
write_plot <- function(variable, output_dir = dir_plots(), ...) {
44+
write_plot <- function(variable, format = 'png', output_dir = dir_plots(), ...) {
4345
filename <- deparse(substitute(variable))
4446

4547
args <- list(plot = variable, ...)
4648

47-
if (is.null(args[['format']])) {
48-
args[['format']] <- 'png'
49-
}
50-
51-
args[['file']] <- here::here(output_dir, glue::glue("{filename}.{args[['format']]}"))
49+
args[['file']] <- here::here(output_dir, glue::glue("{filename}.{format}"))
5250

53-
if (args[['format']] == 'pdf') args[['useDingbats']] <- FALSE
51+
if ('format' == 'pdf') args[['useDingbats']] <- FALSE
5452

5553
do.call(ggplot2::ggsave, args)
5654
}

cran-comments.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
There were no ERRORs, WARNINGs or NOTEs.
99

1010
## Change notes
11-
As requested by reviewer, adds `@return` for `reorder_within`, `scale_x_reordered` and `scale_y_reordered` functions. In DESCRIPTION, added The Globe and Mail Inc. as a copyright holder, and Michael Pereira as a contributor given his work on the main [`startr`](https://github.com/globeandmail/startr) package, which this project was born out of.
11+
Two small bug fixes:
12+
- Adds an extra newline to the `initialize_startr()` log messages so that it stays on its own line.
13+
- Fixes an issue with `write_plot()` where the `format` parameter was inadvertently being passed to `ggsave()`, which would then throw an error.

docs/404.html

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE-text.html

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/authors.html

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/news/index.html

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)