Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhoffa committed Feb 22, 2024
1 parent c34dca5 commit 6c337fb
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
10 changes: 5 additions & 5 deletions R/plot_techmix.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#' region == "global" &
#' metric %in% c("projected", "corporate_economy", "target_sds")
#' ) %>%
#' prep_techmix(
#' span_5yr = TRUE,
#' convert_label = recode_metric_techmix,
#' convert_tech_label = spell_out_technology
#' prep_techmix(
#' span_5yr = TRUE,
#' convert_label = recode_metric_techmix,
#' convert_tech_label = spell_out_technology
#' )
#'
#' plot_techmix(data)
Expand Down Expand Up @@ -81,7 +81,7 @@ check_plot_techmix <- function(data, env) {
"technology_share",
"label",
"label_tech"
)
)
hint_if_missing_names(abort_if_missing_names(data, crucial), "market_share")

abort_if_has_zero_rows(data, env = env)
Expand Down
3 changes: 1 addition & 2 deletions R/prep_emission_intensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
prep_emission_intensity <- function(data,
convert_label = identity,
span_5yr = FALSE) {

check_prep_emission_intensity(
data,
convert_label = convert_label,
span_5yr = span_5yr,
env = list(data = substitute(data))
)
)

out <- data %>%
prep_common()
Expand Down
3 changes: 1 addition & 2 deletions R/prep_techmix.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ prep_techmix <- function(data,
convert_label = identity,
span_5yr = FALSE,
convert_tech_label = identity) {

env <- list(data = substitute(data))
check_prep_techmix(
data,
convert_label = convert_label,
convert_tech_label = convert_tech_label,
span_5yr = span_5yr,
env = env
)
)

out <- data %>%
prep_common() %>%
Expand Down
4 changes: 1 addition & 3 deletions R/prep_trajectory.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ prep_trajectory <- function(data,
convert_label = identity,
span_5yr = FALSE,
value_col = "percentage_of_initial_production_by_scope") {

env <- list(data = substitute(data))
check_prep_trajectory(
data,
convert_label = convert_label,
span_5yr = span_5yr,
value_col = value_col,
env = env
)
)

data <- data %>%
prep_common() %>%
Expand All @@ -59,7 +58,6 @@ check_prep_trajectory <- function(data,
span_5yr,
value_col,
env) {

stopifnot(is.data.frame(data))
stopifnot(is.function(convert_label))
stopifnot(is.logical(span_5yr))
Expand Down
4 changes: 2 additions & 2 deletions R/qplot_emission_intensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ qplot_emission_intensity <- function(data) {
convert_label = to_title,
span_5yr = TRUE,
env = env
)
)

data <- prep_emission_intensity(
data,
convert_label = to_title,
span_5yr = TRUE
)
)

check_plot_emission_intensity(data, env = env)

Expand Down
2 changes: 1 addition & 1 deletion R/qplot_trajectory.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ qplot_trajectory <- function(data) {
plot_trajectory(
center_y = TRUE,
perc_y_scale = TRUE
) %>%
) %>%
labs_trajectory(data)
}

Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-prep_trajectory.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ test_that("returns expected columns", {
})

test_that("handles value_col correctly", {

test_data_dif_value_col <- test_data %>%
rename(new_column = percentage_of_initial_production_by_scope)

Expand All @@ -31,13 +30,12 @@ test_that("handles value_col correctly", {
expect_equal(
setdiff(names(result), names(result_dif_col)),
"percentage_of_initial_production_by_scope"
)
)

expect_equal(
setdiff(names(result_dif_col), names(result)),
"new_column"
)

})

test_that("handles span_5yr correctly", {
Expand Down

0 comments on commit 6c337fb

Please sign in to comment.