Skip to content

Commit 373dae1

Browse files
authored
Merge pull request #75 from ScotGovAnalysis/tidy-lintr
Tidy up lintr issues
2 parents b0dbc11 + efc8c00 commit 373dae1

File tree

13 files changed

+56
-125
lines changed

13 files changed

+56
-125
lines changed

.lintr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ linters: linters_with_defaults(
22
pipe_consistency_linter(pipe = "auto"),
33
object_name_linter(styles = "snake_case", regexes = c("na\\.value"))
44
)
5-
exclude: "^#| fig.alt = "
65
encoding: "UTF-8"

R/colour_table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
colour_table <- function(pal) {
1111

12-
`%>%` <- dplyr::`%>%`
12+
`%>%` <- dplyr::`%>%` # nolint: object_name_linter.
1313

1414
tibble::enframe(pal) %>%
1515
dplyr::mutate(example = "") %>%

R/data.R

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# nolint: start
21
#' @title Scottish Government colours and palettes
32
#'
43
#' @description
5-
#' * \code{sg_colour_values} is a vector containing colour names and their corresponding
6-
#' hex codes.
4+
#' * \code{sg_colour_values} is a vector containing colour names and their
5+
#' corresponding hex codes.
76
#' * \code{sg_colour_palettes} is a list grouping colours into palettes.
87
#'
9-
#' @source \href{https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes}{Scottish Government Design System}
8+
#' @source \href{https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes}{Scottish Government Design System} # nolint: line_length_linter.
109
#' @md
11-
# nolint: end
1210

1311
"sg_colour_values"
1412

@@ -19,12 +17,12 @@
1917
#' @title Social Security Scotland colours and palettes
2018
#'
2119
#' @description
22-
#' * \code{sss_colour_values} is a vector containing colour names and their corresponding
23-
#' hex codes.
20+
#' * \code{sss_colour_values} is a vector containing colour names and their
21+
#' corresponding hex codes.
2422
#' * \code{sss_colour_palettes} is a list grouping colours into palettes.
2523
#'
26-
#' @source Contact the \href{mailto:[email protected]}{Social Security Scotland Statistics mailbox}
27-
#' with any queries about these colours and palettes.
24+
#' @source Contact the \href{mailto:[email protected]}{Social Security Scotland Statistics mailbox} # nolint: line_length_linter.
25+
#' with any queries about these colours and palettes.
2826
#'
2927
#' @md
3028

@@ -34,17 +32,15 @@
3432
"sss_colour_palettes"
3533

3634

37-
# nolint start
3835
#' @title Government Analysis Function colours and palettes
3936
#'
4037
#' @description
41-
#' * \code{af_colour_values} is a vector containing colour names and their corresponding
42-
#' hex codes.
38+
#' * \code{af_colour_values} is a vector containing colour names and their
39+
#' corresponding hex codes.
4340
#' * \code{af_colour_palettes} is a list grouping colours into palettes.
4441
#'
45-
#' @source \href{https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/}{Government Analysis Function Colours Guidance}
42+
#' @source \href{https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/}{Government Analysis Function Colours Guidance} # nolint: line_length_linter.
4643
#' @md
47-
# nolint end
4844

4945
"af_colour_values"
5046

data-raw/af_colours.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Government Analysis Function (AF) colours and palettes
2-
# Source: https://analysisfunction.civilservice.gov.uk/policy-store/
3-
# data-visualisation-colours-in-charts/
1+
#' Government Analysis Function (AF) colours and palettes
2+
#' Source: https://analysisfunction.civilservice.gov.uk/policy-store/data-visualisation-colours-in-charts/ # nolint: line_length_linter.
43

54
af_colour_values <- c(
65
`dark-blue` = "#12436D",

data-raw/sg_colours.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Scottish Government (SG) Design System colours and palettes ----
2-
# Source: https://designsystem.gov.scot/guidance/
3-
# charts/data-visualisation-colour-palettes
1+
#' Scottish Government (SG) Design System colours and palettes
2+
#' Source: https://designsystem.gov.scot/guidance/charts/data-visualisation-colour-palettes # nolint: line_length_linter.
43

54
sg_colour_values <- c(
65
`dark-blue` = "#002d54",

data-raw/sss_colours.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Social Security Scotland (SSS) colours and palettes ----
1+
#' Social Security Scotland (SSS) colours and palettes
22

33
sss_colour_values <- c(
44
`navy` = "#201751",

man/af_colour_values.Rd

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

man/sg_colour_values.Rd

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

man/sss_colour_values.Rd

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

vignettes/articles/cookbook/_annotations.Rmd

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ ann_data <- gapminder |>
1111
filter(country %in% c("United Kingdom", "China"))
1212
```
1313

14-
```{r annotations-1}
15-
#| fig.alt = "A multiple line chart using sgplot theme and main2 palette with lines labelled."
16-
14+
```{r annotations-1, fig.alt = "A multiple line chart using sgplot theme and main2 palette with lines labelled."}
1715
ann_data |>
1816
ggplot() +
1917
geom_line(aes(x = year, y = lifeExp, colour = country), linewidth = 1) +
@@ -45,9 +43,7 @@ However, this makes the code difficult to reuse as values are hard coded and not
4543

4644
One way to automate this is to create a supplementary data frame with desired co-ordinates of the labels (see `ann_labs` in the example below). `nudge` arguments can be used to displace text to improve the positioning.
4745

48-
```{r annotations-2}
49-
#| fig.alt = "A multiple line chart using sgplot theme and main2 palette with lines labelled."
50-
46+
```{r annotations-2, fig.alt = "A multiple line chart using sgplot theme and main2 palette with lines labelled."}
5147
ann_labs <- ann_data |>
5248
group_by(country) |>
5349
filter(year == max(year)) |>
@@ -80,9 +76,7 @@ ann_data |>
8076

8177
Annotations may also be used to add value labels to a bar chart. Note that `geom_text()` is used here as a background is not required.
8278

83-
```{r annotations-3}
84-
#| fig.alt = "A bar chart with white text labels at the end of each bar."
85-
79+
```{r annotations-3, fig.alt = "A bar chart with white text labels at the end of each bar."}
8680
ggplot(bar_data, aes(x = reorder(country, -pop), y = pop)) +
8781
geom_col(fill = sg_colour_values["dark-blue"]) +
8882
geom_text(aes(label = format(pop, big.mark = ",")),

0 commit comments

Comments
 (0)