-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
152 lines (101 loc) · 5.82 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# dfeR <a href="http://dfe-analytical-services.github.io/dfeR/"><img src="man/figures/logo.png" align="right" height="138" /></a>
<!-- badges: start -->
[![R-CMD-check](https://github.com/dfe-analytical-services/dfeR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dfe-analytical-services/dfeR/actions/workflows/R-CMD-check.yaml)
[![pkgdown](https://github.com/dfe-analytical-services/dfeR/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/dfe-analytical-services/dfeR/actions/workflows/pkgdown.yaml)
[![Codecov test coverage](https://codecov.io/gh/dfe-analytical-services/dfeR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/dfe-analytical-services/dfeR?branch=main)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
The goal of dfeR is to help standardise R programming across the Department for Education (DfE), and facilitate sharing of business specific functions, making our code easier to read and write.
Credit to [lauraselby](https://github.com/lauraselby) for the logo featuring Frederick!
## Scope
This package is open to all of DfE and anything we think could be useful to other programmers and analysts can be contributed.
Functionality for dfeR is expected to focus around the following:
1. DfE specific formatting and helper functions
2. Working with DfE databases
3. Templates for analytical projects
4. API wrappers commonly needed in DfE analysis (where they don't have their own separate package)
5. Geography lookup files and helper functions
Documentation for what has been included in the package so far is on our [pkgdown site](http://dfe-analytical-services.github.io/dfeR/).
### Relevant other packages
We also maintain the [dfeshiny](https://github.com/dfe-analytical-services/dfeshiny) package, and expect any functions specific to R Shiny applications will live there.
For connecting to data in the [explore education statistics](https://explore-education-statistics.service.gov.uk/), we are building the [eesyapi](https://github.com/dfe-analytical-services/eesyapi) package.
There is a [giasr](https://github.com/dfe-analytical-services/giasr) package, which has been developed for connecting to data in the [get information about schools service](https://get-information-schools.service.gov.uk/).
While we have some DfE specific data in the dfeR package taken from the [Open Geography Portal](https://geoportal.statistics.gov.uk/). If you're looking at getting new data from the portal it is also worth looking at the [boundr](https://github.com/francisbarton/boundr) package, as this gives more functions for directly extracting data from there.
---
## Installation
dfeR is not currently available on CRAN. For the time being you can install the development version from GitHub.
If you are using [renv](https://rstudio.github.io/renv/articles/renv.html) in your project (recommended):
``` r
renv::install("dfe-analytical-services/dfeR")
```
Otherwise:
``` r
# install.packages("devtools")
devtools::install_github("dfe-analytical-services/dfeR")
```
---
## Proxy
The need for setting proxy settings in order to be able to work with R and Git within the DfE estate has now ended. If you previously run the proxy script in previous versions of the dfeR package, then contact the [Statistics Development Team]([email protected]) to assist in cleaning out your system settings.
---
## Contributing
Ideas for dfeR should first be raised as a [GitHub issue](https://github.com/dfe-analytical-services/dfeR) after which anyone is free to write the code and create a pull request for review.
For more details on contributing to dfeR, see our [contributing guidelines](https://dfe-analytical-services.github.io/dfeR/CONTRIBUTING.html).
---
## Code of Conduct
Please note that the dfeR project is released with a [Contributor Code of Conduct](https://dfe-analytical-services.github.io/dfeR/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
---
## Examples
Here are some example functions from within the package:
```{r example}
library(dfeR)
# Prettify large numbers
pretty_num(111111111, gbp = TRUE)
pretty_num(-11^8, dp = -1)
# Convert bytes to readable size
pretty_filesize(77777777)
# Calculate elapsed time and present prettily
start <- Sys.time()
end <- Sys.time() + 789890
pretty_time_taken(start, end)
# Round 5's up instead of bankers round used by round() in base R
round_five_up(2.5)
round(2.5) # base R
# Custom formatting for academic and financial years
format_ay(202425)
format_fy(202425)
format_ay_reverse("2024/25")
format_fy_reverse("2024-25")
# Get Ward to PCon to LAD to LA to Rgn to Ctry lookup file
my_data <- dfeR::wd_pcon_lad_la_rgn_ctry
head(my_data) # show first 5 rows in console
# Get all countries
dfeR::countries
# Get all PCon names and codes for 2024
fetch_pcons(2024) |>
head() # show first 5 rows only
# Get All LADs in Scotland in 2017
fetch_lads(2017, "Scotland") |>
head() # show first 5 rows only
# Get all LAs in Scotland and Northern Ireland in 2022
fetch_las(2022, c("Scotland", "Northern Ireland")) |>
head() # show first 5 rows only
# Get all Welsh wards for 2021
fetch_wards(2021, "Wales") |>
head() # show first 5 rows only
# The following have no specific years available and return all values
fetch_regions()
fetch_countries()
```
For more details on all the functions available in this package, and examples of how to use them, please see our [dfeR package reference documentation](https://dfe-analytical-services.github.io/dfeR/reference/index.html).