Skip to content

Commit 89484b2

Browse files
authored
Merge branch 'master' into add-dependabot
2 parents 10dda6a + 53206ed commit 89484b2

File tree

9 files changed

+230
-77
lines changed

9 files changed

+230
-77
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Imports:
4040
scales (>= 1.0.0),
4141
stringr,
4242
tibble,
43-
utils
43+
utils,
44+
withr
4445
Suggests:
4546
covr,
4647
ggplot2,

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# phsmethods (development version)
22

3+
- `file_size()` has been deprecated as we believe it is no longer relevant ([#11](https://github.com/Public-Health-Scotland/phsmethods/issues/11)).
4+
Please let us know if you still have a use for it, otherwise it will be removed
5+
in a future version.
6+
37
# phsmethods 1.0.2 (2024-01-05)
48

59
- No user-facing changes. Fix some tests for `age_from_chi()` due to a helper

R/file_size.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#' @title Calculate file size
22
#'
3-
#' @description `file_size` takes a filepath and an optional regular
3+
#' @description
4+
#' `r lifecycle::badge('deprecated')`
5+
#'
6+
#' `file_size` takes a filepath and an optional regular
47
#' expression pattern. It returns the size of all files within that directory
58
#' which match the given pattern.
69
#'
10+
#' @keywords internal
11+
#'
712
#' @details The sizes of files with certain extensions are returned with the
813
#' type of file prefixed. For example, the size of a 12 KB `.xlsx` file is
914
#' returned as `Excel 12 KB`. The complete list of explicitly catered-for file
@@ -65,7 +70,7 @@
6570
#' library(magrittr)
6671
#' file_size() %>%
6772
#' dplyr::pull(size) %>%
68-
#' extract(1)
73+
#' magrittr::extract(1)
6974
#'
7075
#' @seealso For more information on using regular expressions, see this
7176
#' [Jumping Rivers blog post](https://www.jumpingrivers.com/blog/regular-expressions-every-r-programmer-should-know/)
@@ -75,6 +80,14 @@
7580
#'
7681
#' @export
7782
file_size <- function(filepath = getwd(), pattern = NULL) {
83+
lifecycle::deprecate_warn(
84+
"1.1.0",
85+
"file_size()",
86+
details = "We think it is redundant, but if you still have a need for this
87+
function, please get in touch.",
88+
always = TRUE
89+
)
90+
7891
if (!file.exists(filepath)) {
7992
cli::cli_abort("A valid {.arg filepath} must be supplied.")
8093
}

README.Rmd

Lines changed: 132 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,62 @@ knitr::opts_chunk$set(
1313
```
1414

1515
# phsmethods
16+
1617
<!-- badges: start -->
17-
[![CRAN status](https://www.r-pkg.org/badges/version/phsmethods)](https://CRAN.R-project.org/package=phsmethods)
18-
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Public-Health-Scotland/phsmethods)](https://github.com/Public-Health-Scotland/phsmethods/releases/latest)
19-
[![Build Status](https://github.com/Public-Health-Scotland/phsmethods/workflows/R-CMD-check/badge.svg)](https://github.com/Public-Health-Scotland/phsmethods/actions)
20-
[![codecov](https://codecov.io/gh/Public-Health-Scotland/phsmethods/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Public-Health-Scotland/phsmethods)
21-
<!-- badges: end -->
2218

23-
`phsmethods` contains functions for commonly undertaken analytical tasks in [Public Health Scotland (PHS)](https://www.publichealthscotland.scot/):
19+
[![CRAN
20+
status](https://www.r-pkg.org/badges/version/phsmethods)](https://CRAN.R-project.org/package=phsmethods)
21+
[![GitHub release (latest by
22+
date)](https://img.shields.io/github/v/release/Public-Health-Scotland/phsmethods)](https://github.com/Public-Health-Scotland/phsmethods/releases/latest)
23+
[![Build
24+
Status](https://github.com/Public-Health-Scotland/phsmethods/workflows/R-CMD-check/badge.svg)](https://github.com/Public-Health-Scotland/phsmethods/actions)
25+
[![codecov](https://codecov.io/gh/Public-Health-Scotland/phsmethods/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Public-Health-Scotland/phsmethods)
2426

25-
- `create_age_groups()` categorises ages into groups
26-
- `chi_check()` assesses the validity of a CHI number
27-
- `chi_pad()` adds a leading zero to nine-digit CHI numbers
28-
- `sex_from_chi()` extracts the sex of a person from a CHI number
29-
- `file_size()` returns the names and sizes of files in a directory
30-
- `extract_fin_year()` assigns a date to a financial year in the format `YYYY/YY`
31-
- `match_area()` converts geography codes into area names
32-
- `format_postcode()` formats improperly recorded postcodes
33-
- `qtr()`, `qtr_end()`, `qtr_next()` and `qtr_prev()` assign a date to a quarter
34-
- `age_calculate()` calculates age between two dates
35-
- `dob_from_chi()` extracts Date of Birth (DoB) from the CHI number
36-
- `age_from_chi()` extracts age from the CHI number
27+
<!-- badges: end -->
3728

38-
`phsmethods` can be used on both the PHS server and desktop versions of RStudio.
29+
`phsmethods` contains functions for commonly undertaken analytical tasks
30+
in [Public Health Scotland
31+
(PHS)](https://www.publichealthscotland.scot/):
32+
33+
- `create_age_groups()` categorises ages into groups.
34+
- `chi_check()` assesses the validity of a CHI number.
35+
- `chi_pad()` adds a leading zero to nine-digit CHI numbers.
36+
- `sex_from_chi()` extracts the sex of a person from a CHI number.
37+
- `extract_fin_year()` assigns a date to a financial year in the
38+
format `YYYY/YY`.
39+
- `match_area()` converts geography codes into area names.
40+
- `format_postcode()` formats improperly recorded postcodes.
41+
- `qtr()`, `qtr_end()`, `qtr_next()` and `qtr_prev()` assign a date to
42+
a quarter.
43+
- `age_calculate()` calculates age between two dates.
44+
- `dob_from_chi()` extracts Date of Birth (DoB) from the CHI number.
45+
- `age_from_chi()` extracts age from the CHI number.
46+
47+
`phsmethods` can be used on both the PHS server and desktop versions of
48+
RStudio.
3949

4050
## Installation
4151

42-
If you are using the PHS Posit Workbench the default repository is the PHS Posit Package Manager, the benefit of this is that `phsmethods` is listed there so you can install it with:
52+
If you are using the PHS Posit Workbench the default repository is the
53+
PHS Posit Package Manager, the benefit of this is that `phsmethods` is
54+
listed there so you can install it with:
4355

4456
``` r
4557
install.packages("phsmethods")
4658
```
4759

48-
To install `phsmethods` directly from GitHub, the package `remotes` is required, and can be
49-
installed with `install.packages("remotes")`.
60+
To install `phsmethods` directly from GitHub, the package `remotes` is
61+
required, and can be installed with `install.packages("remotes")`.
5062

5163
You can then install `phsmethods` from GitHub with:
5264

5365
``` r
5466
remotes::install_github("Public-Health-Scotland/phsmethods")
5567
```
5668

57-
However, network security settings may prevent `remotes::install_github()` from
58-
working on RStudio desktop. If this is the case, `phsmethods` can be
59-
installed by downloading the [zip of the
69+
However, network security settings may prevent
70+
`remotes::install_github()` from working on RStudio desktop. If this is
71+
the case, `phsmethods` can be installed by downloading the [zip of the
6072
repository](https://github.com/Public-Health-Scotland/phsmethods/archive/master.zip)
6173
and running the following code (replacing the section marked `<>`,
6274
including the arrows themselves):
@@ -75,42 +87,108 @@ Load `phsmethods` using `library()`:
7587
library(phsmethods)
7688
```
7789

78-
To see the documentation for any `phsmethods`' functions, type `?function_name` into the RStudio console after loading the package:
90+
To see the documentation for any `phsmethods`' functions, type
91+
`?function_name` into the RStudio console after loading the package:
7992

8093
```{r help, eval = FALSE}
8194
?extract_fin_year
8295
?format_postcode
8396
```
8497

85-
You can access the full list of functions and their help pages on [Reference page of pkgdown website](https://public-health-scotland.github.io/phsmethods/reference/index.html). You will be able to see some examples of each function.
98+
You can access the full list of functions and their help pages on
99+
[Reference page of pkgdown
100+
website](https://public-health-scotland.github.io/phsmethods/reference/index.html).
101+
You will be able to see some examples of each function.
86102

87-
There is also a very useful [PHS Methods online training course](https://scotland.shinyapps.io/phs-learnr-phsmethods) which gives you an interactive way to learn about this package.
103+
There is also a very useful [PHS Methods on-line training
104+
course](https://scotland.shinyapps.io/phs-learnr-phsmethods) which gives
105+
you an interactive way to learn about this package.
88106

89107
## Contributing to phsmethods
90108

91-
At present, the maintainer of this package is [Tina Fu](https://github.com/Tina815).
92-
93-
This package is intended to be in continuous development and contributions may be made by anyone within PHS. If you would like to contribute, please first create an [issue](https://github.com/Public-Health-Scotland/phsmethods/issues) on GitHub and assign **both** of the package maintainers to it. This is to ensure that no duplication of effort occurs in the case of multiple people having the same idea. The package maintainers will discuss the issue and get back to you as soon as possible.
94-
95-
While the most obvious and eye-catching (as well as intimidating) way of contributing is by writing a function, this isn't the only way to make a useful contribution. Fixing typos in documentation, for example, isn't the most glamorous way to contribute, but is of great help to the package maintainers. Please see this [blog post by Jim Hester](https://www.tidyverse.org/blog/2017/08/contributing/) for more information on getting started with contributing to open-source software.
96-
97-
When contributing, please create a [branch](https://github.com/Public-Health-Scotland/phsmethods/branches) in this repository and carry out all work on it. Please ensure you have linked RStudio to your GitHub account using `usethis::edit_git_config()` prior to making your contribution. When you are ready for a review, please create a [pull request](https://github.com/Public-Health-Scotland/phsmethods/pulls) and assign **both** of the package maintainers as reviewers. One or both of them will conduct a review, provide feedback and, if necessary, request changes before merging your branch.
98-
99-
Please be mindful of information governance when contributing to this package. No data files (aside from publicly available and downloadable datasets or unless explicitly approved), server connection details, passwords or person identifiable or otherwise confidential information should be included anywhere within this package or any other repository (whether public or private) used within PHS. This includes within code and code commentary. For more information on security when using git and GitHub, and on using git and GitHub for version control more generally, please see the [Transforming Publishing Programme](https://www.isdscotland.org/Products-and-Services/Transforming-Publishing-Programme/)'s [Git guide](https://Public-Health-Scotland.github.io/git-guide/) and [GitHub guidance](https://github.com/Public-Health-Scotland/GitHub-guidance).
100-
101-
Please feel free to add yourself to the 'Authors' section of the `Description` file when contributing. As a rule of thumb, please assign your role as author (`"aut"`) when writing an exported function, and as contributor (`"ctb"`) for anything else.
102-
103-
`phsmethods` will, as much as possible, adhere to the [tidyverse style guide](https://style.tidyverse.org/) and the [rOpenSci package development guide](https://devguide.ropensci.org/). The most pertinent points to take from these are:
104-
105-
- All function names should be in lower case, with words separated by an underscore
106-
- Put a space after a comma, never before
107-
- Put a space before and after infix operators such as `<-`, `==` and `+`
108-
- Limit code to 80 characters per line
109-
- Function documentation should be generated using [`roxygen2`](https://github.com/r-lib/roxygen2)
110-
- All functions should be tested using [`testthat`](https://github.com/r-lib/testthat)
111-
- The package should always pass `devtools::check()`
112-
113-
It's not necessary to have experience with GitHub or of building an R package to contribute to `phsmethods`. If you wish to contribute code then, as long as you can write an R function, the package maintainers can assist with error handling, writing documentation, testing and other aspects of package development. It is advised, however, to consult [Hadley Wickham's R Packages book](https://r-pkgs.org/) prior to making a contribution. It may also be useful to consult the [documentation](https://github.com/Public-Health-Scotland/phsmethods/tree/master/R) and [tests](https://github.com/Public-Health-Scotland/phsmethods/tree/master/tests/testthat) of existing functions within this package as a point of reference.
114-
115-
Please note that this README may fail to 'Knit' at times as a result of network security settings. This will likely be due to the badges for the package's release version, continuous integration status and test coverage at the top of the document. You should only make edits to the `.Rmd` version, you can then knit yourself, or a GitHub action should run and knit it for you when you open a pull request.
116-
109+
At present, the maintainer of this package is [Tina
110+
Fu](https://github.com/Tina815).
111+
112+
This package is intended to be in continuous development and
113+
contributions may be made by anyone within PHS. If you would like to
114+
contribute, please first create an
115+
[issue](https://github.com/Public-Health-Scotland/phsmethods/issues) on
116+
GitHub and assign **both** of the package maintainers to it. This is to
117+
ensure that no duplication of effort occurs in the case of multiple
118+
people having the same idea. The package maintainers will discuss the
119+
issue and get back to you as soon as possible.
120+
121+
While the most obvious and eye-catching (as well as intimidating) way of
122+
contributing is by writing a function, this isn't the only way to make a
123+
useful contribution. Fixing typos in documentation, for example, isn't
124+
the most glamorous way to contribute, but is of great help to the
125+
package maintainers. Please see this [blog post by Jim
126+
Hester](https://www.tidyverse.org/blog/2017/08/contributing/) for more
127+
information on getting started with contributing to open-source
128+
software.
129+
130+
When contributing, please create a
131+
[branch](https://github.com/Public-Health-Scotland/phsmethods/branches)
132+
in this repository and carry out all work on it. Please ensure you have
133+
linked RStudio to your GitHub account using `usethis::edit_git_config()`
134+
prior to making your contribution. When you are ready for a review,
135+
please create a [pull
136+
request](https://github.com/Public-Health-Scotland/phsmethods/pulls) and
137+
assign **both** of the package maintainers as reviewers. One or both of
138+
them will conduct a review, provide feedback and, if necessary, request
139+
changes before merging your branch.
140+
141+
Please be mindful of information governance when contributing to this
142+
package. No data files (aside from publicly available and downloadable
143+
datasets or unless explicitly approved), server connection details,
144+
passwords or person identifiable or otherwise confidential information
145+
should be included anywhere within this package or any other repository
146+
(whether public or private) used within PHS. This includes within code
147+
and code commentary. For more information on security when using git and
148+
GitHub, and on using git and GitHub for version control more generally,
149+
please see the [Transforming Publishing
150+
Programme](https://www.isdscotland.org/Products-and-Services/Transforming-Publishing-Programme/)'s
151+
[Git guide](https://Public-Health-Scotland.github.io/git-guide/) and
152+
[GitHub
153+
guidance](https://github.com/Public-Health-Scotland/GitHub-guidance).
154+
155+
Please feel free to add yourself to the 'Authors' section of the
156+
`Description` file when contributing. As a rule of thumb, please assign
157+
your role as author (`"aut"`) when writing an exported function, and as
158+
contributor (`"ctb"`) for anything else.
159+
160+
`phsmethods` will, as much as possible, adhere to the [tidyverse style
161+
guide](https://style.tidyverse.org/) and the [rOpenSci package
162+
development guide](https://devguide.ropensci.org/). The most pertinent
163+
points to take from these are:
164+
165+
- All function names should be in lower case, with words separated by
166+
an underscore
167+
- Put a space after a comma, never before
168+
- Put a space before and after infix operators such as `<-`, `==` and
169+
`+`
170+
- Limit code to 80 characters per line
171+
- Function documentation should be generated using
172+
[`roxygen2`](https://github.com/r-lib/roxygen2)
173+
- All functions should be tested using
174+
[`testthat`](https://github.com/r-lib/testthat)
175+
- The package should always pass `devtools::check()`
176+
177+
It's not necessary to have experience with GitHub or of building an R
178+
package to contribute to `phsmethods`. If you wish to contribute code
179+
then, as long as you can write an R function, the package maintainers
180+
can assist with error handling, writing documentation, testing and other
181+
aspects of package development. It is advised, however, to consult
182+
[Hadley Wickham's R Packages book](https://r-pkgs.org/) prior to making
183+
a contribution. It may also be useful to consult the
184+
[documentation](https://github.com/Public-Health-Scotland/phsmethods/tree/master/R)
185+
and
186+
[tests](https://github.com/Public-Health-Scotland/phsmethods/tree/master/tests/testthat)
187+
of existing functions within this package as a point of reference.
188+
189+
Please note that this README may fail to 'Knit' at times as a result of
190+
network security settings. This will likely be due to the badges for the
191+
package's release version, continuous integration status and test
192+
coverage at the top of the document. You should only make edits to the
193+
`.Rmd` version, you can then knit yourself, or a GitHub action should
194+
run and knit it for you when you open a pull request.

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ date)](https://img.shields.io/github/v/release/Public-Health-Scotland/phsmethods
1212
[![Build
1313
Status](https://github.com/Public-Health-Scotland/phsmethods/workflows/R-CMD-check/badge.svg)](https://github.com/Public-Health-Scotland/phsmethods/actions)
1414
[![codecov](https://codecov.io/gh/Public-Health-Scotland/phsmethods/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Public-Health-Scotland/phsmethods)
15+
1516
<!-- badges: end -->
1617

1718
`phsmethods` contains functions for commonly undertaken analytical tasks
1819
in [Public Health Scotland
1920
(PHS)](https://www.publichealthscotland.scot/):
2021

21-
- `create_age_groups()` categorises ages into groups
22-
- `chi_check()` assesses the validity of a CHI number
23-
- `chi_pad()` adds a leading zero to nine-digit CHI numbers
24-
- `sex_from_chi()` extracts the sex of a person from a CHI number
25-
- `file_size()` returns the names and sizes of files in a directory
22+
- `create_age_groups()` categorises ages into groups.
23+
- `chi_check()` assesses the validity of a CHI number.
24+
- `chi_pad()` adds a leading zero to nine-digit CHI numbers.
25+
- `sex_from_chi()` extracts the sex of a person from a CHI number.
2626
- `extract_fin_year()` assigns a date to a financial year in the format
27-
`YYYY/YY`
28-
- `match_area()` converts geography codes into area names
29-
- `format_postcode()` formats improperly recorded postcodes
27+
`YYYY/YY`.
28+
- `match_area()` converts geography codes into area names.
29+
- `format_postcode()` formats improperly recorded postcodes.
3030
- `qtr()`, `qtr_end()`, `qtr_next()` and `qtr_prev()` assign a date to a
31-
quarter
32-
- `age_calculate()` calculates age between two dates
33-
- `dob_from_chi()` extracts Date of Birth (DoB) from the CHI number
34-
- `age_from_chi()` extracts age from the CHI number
31+
quarter.
32+
- `age_calculate()` calculates age between two dates.
33+
- `dob_from_chi()` extracts Date of Birth (DoB) from the CHI number.
34+
- `age_from_chi()` extracts age from the CHI number.
3535

3636
`phsmethods` can be used on both the PHS server and desktop versions of
3737
RStudio.
@@ -89,7 +89,7 @@ You can access the full list of functions and their help pages on
8989
website](https://public-health-scotland.github.io/phsmethods/reference/index.html).
9090
You will be able to see some examples of each function.
9191

92-
There is also a very useful [PHS Methods online training
92+
There is also a very useful [PHS Methods on-line training
9393
course](https://scotland.shinyapps.io/phs-learnr-phsmethods) which gives
9494
you an interactive way to learn about this package.
9595

0 commit comments

Comments
 (0)