Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial CRAN release #103

Merged
merged 8 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
^data-raw$
^doc$
^Meta$
^cran-comments\.md$
14 changes: 8 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
Type: Package
Package: dfeR
Title: Common DfE R tasks
Version: 0.6.1.9000
Title: Common Department for Education Analysis Tasks
Version: 1.0.1
Authors@R: c(
person("Cam", "Race", , "[email protected]", role = c("aut", "cre")),
person("Department for Education, England", , , "[email protected]", role = "cph"),
person("Laura", "Selby", , "[email protected]", role = "aut"),
person("Adam", "Robinson", role = "aut"),
person("Jen", "Machin", , "[email protected]", role = "ctb"),
person("Jake", "Tufts", , "[email protected]", role = "ctb"),
person("Rich", "Bielby", , "[email protected]", role = "ctb",
comment = c(ORCID = "0000-0001-9070-9969")),
person("Menna", "Zayed", , "[email protected]", role = "ctb")
person("Menna", "Zayed", , "[email protected]", role = "ctb"),
person("Lauren", "Snaathorst", , "[email protected]", role = "ctb")
)
Description: This package contains R functions to allow DfE analysts to
re-use code for common analytical tasks that are undertaken across the
Department.
Description: Preferred methods for common analytical tasks that are
undertaken across the Department, including number formatting, project
templates and curated reference data.
License: GPL (>= 3)
URL: https://dfe-analytical-services.github.io/dfeR/,
https://github.com/dfe-analytical-services/dfeR
Expand Down
9 changes: 7 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# dfeR (development version)
# dfeR 1.0.1

Added lookup data geog_time_identifiers
Fix the spacing and printing of the z_replace() warning message, updating the eesyapi URL in the README and removed extraneous package tests.

# dfeR 1.0.0

Initial CRAN release.
Added lookup data geog_time_identifiers.
Added z_replace() to replace NA values in tables except for ones in geography and time columns that match ones in geog_time_identifiers.

# dfeR 0.6.1
Expand Down
15 changes: 6 additions & 9 deletions R/create_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ create_project <- function(
"call those functions, run\n",
"# `source('R/helper_functions.R')` at the start of your ",
"script.\n\n",
"print('Your scripts and functions should be in ",
"message('Your scripts and functions should be in ",
"the R folder.')"
)
)
Expand Down Expand Up @@ -175,7 +175,10 @@ create_project <- function(


# Create the readme -----
file.copy("README_template.md", file.path(path, "README.md"))
file.copy(
system.file(package = "dfeR", "README_template.md"),
file.path(path, "README.md")
)

# .renvignore
file.create(paste0(path, "/.renvignore"))
Expand Down Expand Up @@ -242,8 +245,6 @@ create_project <- function(
)
}



# Create a .Rprofile with a custom welcome message
if (!file.exists(paste0(path, "/.Rprofile"))) {
file.create(paste0(path, "/.Rprofile"))
Expand All @@ -267,13 +268,9 @@ create_project <- function(
)
writeLines(rprofile_content, paste0(path, "/.Rprofile"))





# Successful project creation message (or delete project if fails)
if (successful_creation) {
cat(
message(
paste0(
"\n\n",
"****************************************************************\n",
Expand Down
2 changes: 1 addition & 1 deletion R/datasets_documentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@
#' @format ## `geog_time_identifiers`
#' A character vector with 38 potential column names in snake case format.
#' @source curated by explore.statistics@@education.gov.uk.
#' \href{https://shorturl.at/j4532}{Get guidance on time and geography data.}
#' \href{https://www.shorturl.at/j4532}{Guidance on time and geography data.}
"geog_time_identifiers"
4 changes: 4 additions & 0 deletions R/datasets_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' data frame from R memory
#'
#' @keywords internal
#' @noRd
#' @return a data frame of a tidied lookup file
tidy_raw_lookup <- function(raw_lookup_file) {
if (!is.data.frame(raw_lookup_file)) {
Expand Down Expand Up @@ -142,6 +143,7 @@ tidy_raw_lookup <- function(raw_lookup_file) {
#' usually the output of tidy_raw_lookup
#'
#' @return single data.frame of all lookup files combined
#' @noRd
create_time_series_lookup <- function(lookups_list) {
# Input validation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Added some quick checks based on the assumptions we make in this function
Expand Down Expand Up @@ -234,6 +236,7 @@ create_time_series_lookup <- function(lookups_list) {
#' @return data.frame for the individual year of the lookup
#'
#' @keywords internal
#' @noRd
get_wd_pcon_lad_la <- function(year) {
# Crude way to grab 2 digits, works for anything that isn't in the noughties
year_end <- year %% 100
Expand Down Expand Up @@ -304,6 +307,7 @@ get_wd_pcon_lad_la <- function(year) {
#' @return data.frame for the individual year of the lookup
#'
#' @keywords internal
#' @noRd
get_lad_region <- function(year) {
# Crude way to grab 2 digits, works for anything that isn't in the noughties
year_end <- year %% 100
Expand Down
2 changes: 2 additions & 0 deletions R/fetch_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#'
#' @return nothing, unless a failure, and then it will give an error
#' @keywords internal
#' @noRd
check_fetch_location_inputs <- function(year_input, country_input) {
if (year_input != "All") {
if (!grepl("^\\d{4}$", as.character(year_input))) {
Expand Down Expand Up @@ -39,6 +40,7 @@ check_fetch_location_inputs <- function(year_input, country_input) {
#'
#' @return a data frame of location names and codes
#' @keywords internal
#' @noRd
fetch_locations <- function(lookup_data, cols, year, countries) {
# Return only the cols we specified
# We know their position from the dplyr selection of the lookup
Expand Down
24 changes: 13 additions & 11 deletions R/get_ons_api_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' Geography Portal
#' @param query_params query parameters to pass into the API, see the ESRI
#' documentation for more information on query parameters -
#' \href{https://shorturl.at/5xrJT}{ESRI Query (Feature Service/Layer)}
#' \href{https://www.shorturl.at/5xrJT}{ESRI Query (Feature Service/Layer)}
#' @param batch_size the number of rows per query. This is 250 by default, if
#' you hit errors then try lowering this. The API has a limit of 1000 to 2000
#' rows per query, and in truth, the actual limit for our method is lower as
Expand All @@ -36,17 +36,19 @@
#' @return parsed data.frame of geographic names and codes
#'
#' @examples
#' if (interactive()) {
#' # Specify some parameters
#' get_ons_api_data(
#' data_id = "LAD23_RGN23_EN_LU",
#' query_params =
#' list(outFields = "column1, column2", outSR = "4326", f = "json")
#' )
#' # Fetch everything from a data set
#' dfeR::get_ons_api_data(data_id = "LAD23_RGN23_EN_LU")
#'
#' # Just fetch everything
#' get_ons_api_data(data_id = "LAD23_RGN23_EN_LU")
#' }
#' # Specify the columns you want
#' dfeR::get_ons_api_data(
#' "RGN_DEC_2023_EN_NC",
#' query_params = list(
#' where = "1=1",
#' outFields = "RGN23CD,RGN23NM",
#' outSR = 4326,
#' f = "json"
#' )
#' )
get_ons_api_data <- function(data_id,
query_params =
list(
Expand Down
2 changes: 2 additions & 0 deletions R/toggle_message.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' @param verbose logical, usually a variable passed from the function you are
#' using this within
#'
#' @return No return value, called for side effects
#'
#' @export
#'
#' @examples
Expand Down
4 changes: 2 additions & 2 deletions R/z_replace.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @description
#' Replaces `NA` values in tables except for ones in time and geography
#' columns that must be included in DfE official statistics.
#' \href{https://shorturl.at/chy76}{Get more guidance on Open Data Standards.}
#' \href{https://www.shorturl.at/chy76}{Guidance on our Open Data Standards.}
#'
#' @details

Expand Down Expand Up @@ -87,7 +87,7 @@ z_replace <- function(data,
stop(
"Your table has geography and/or time column(s) that are not ",
"in snake_case.\nPlease amend your column names to match the formatting",
"to dfeR::geog_time_identifiers."
" of dfeR::geog_time_identifiers."
)
}

Expand Down
16 changes: 11 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ knitr::opts_chunk$set(
)
```

# dfeR <a href="http://dfe-analytical-services.github.io/dfeR/"><img src="man/figures/logo.png" align="right" height="138" /></a>
# dfeR <a href="https://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)
Expand All @@ -38,13 +38,13 @@ Functionality for dfeR is expected to focus around the following:
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/).
Documentation for what has been included in the package so far is on our [pkgdown site](https://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.
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.R) 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/).

Expand All @@ -54,7 +54,13 @@ While we have some DfE specific data in the dfeR package taken from the [Open Ge

## Installation

dfeR is not currently available on CRAN. For the time being you can install the development version from GitHub.
dfeR is available on CRAN and you can install directly from there:

``` r
install.packages("dfeR")
```

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):

Expand All @@ -73,7 +79,7 @@ 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.
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](mailto:[email protected]) to assist in cleaning out your system settings.

---

Expand Down
Loading
Loading