Skip to content

Commit

Permalink
Rename package aftables
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivia-Box-Power committed Feb 3, 2025
1 parent 1721fcf commit 49ae3bd
Show file tree
Hide file tree
Showing 53 changed files with 544 additions and 534 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
^a11ytables\.Rproj$
^aftables\.Rproj$
^\.Rproj\.user$
^data-raw$
^README\.Rmd$
Expand All @@ -11,3 +11,4 @@
^codecov\.yml$
^doc$
^Meta$
^cran-comments\.md$
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Code of Conduct for `a11ytables`
# Code of Conduct for `aftables`

## Civil Service Code

Expand Down
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to {a11ytables}
# Contributing to {aftables}

This outlines how to propose a change to {a11ytables}.
This outlines how to propose a change to {aftables}.

## Fixing typos

Expand Down
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: a11ytables
Package: aftables
Title: Create Spreadsheet Publications Following Best Practice
Version: 0.3.2
Version: 1.0.0
Authors@R: c(
person("Matt", "Dray", , "[email protected]", role = c("aut")),
person("Tim", "Taylor", role = "ctb"),
Expand All @@ -13,11 +13,11 @@ Description: Generate spreadsheet publications that follow best practice
accessibility. Based on 'openxlsx'. See also the Python package
'gptables'.
License: MIT + file LICENSE
URL: https://best-practice-and-impact.github.io/a11ytables/,
https://github.com/best-practice-and-impact/a11ytables
BugReports: https://github.com/best-practice-and-impact/a11ytables/issues
URL: https://best-practice-and-impact.github.io/aftables/,
https://github.com/best-practice-and-impact/aftables
BugReports: https://github.com/best-practice-and-impact/aftables/issues
Depends:
R (>= 2.10)
R (>= 3.5)
Imports:
openxlsx,
pillar
Expand Down
12 changes: 6 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Generated by roxygen2: do not edit by hand

S3method(summary,a11ytable)
S3method(tbl_sum,a11ytable)
export(as_a11ytable)
export(at_template_a11ytable)
S3method(summary,aftable)
S3method(tbl_sum,aftable)
export(as_aftable)
export(at_template_aftable)
export(at_template_workflow)
export(create_a11ytable)
export(create_aftable)
export(generate_workbook)
export(is_a11ytable)
export(is_aftable)
importFrom(pillar,tbl_sum)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# aftables 1.0.0

* Updated package name to aftables. Function names have been updated to remove references to a11ytables.


# a11ytables 0.3.2

* Bug fix: ensured factors are converted to character before assessing whether the column needs to be widened (#110, #113).
Expand Down
42 changes: 21 additions & 21 deletions R/addin.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#' Insert Demo 'create_a11ytable' Template
#' Insert Demo 'create_aftable' Template
#'
#' Insert at the cursor a template for \code{\link{create_a11ytable}} from the
#' 'a11ytable' package, pre-filled with demo data.
#' Insert at the cursor a template for \code{\link{create_aftable}} from the
#' 'aftable' package, pre-filled with demo data.
#'
#' @export
at_template_a11ytable <- function() {
rstudioapi::insertText(string_create_a11ytable())
at_template_aftable <- function() {
rstudioapi::insertText(string_create_aftable())
}

#' Insert Full Demo 'a11ytables' Template Workflow
#' Insert Full Demo 'aftables' Template Workflow
#'
#' Insert at the cursor (a) demo templates for cover, contents and notes
#' tables, and (b) a call to \code{\link{create_a11ytable}} pre-filled with
#' tables, and (b) a call to \code{\link{create_aftable}} pre-filled with
#' demo data.
#'
#' @export
Expand All @@ -23,13 +23,13 @@ at_template_workflow <- function() {
"\n\n",
string_tables(),
"\n\n",
"# Create new a11ytable",
"# Create new aftable",
"\n\n",
string_create_a11ytable(),
string_create_aftable(),
"\n\n",
"# Generate workbook from a11ytable",
"# Generate workbook from aftable",
"\n\n",
"my_wb <- a11ytables::generate_workbook(my_a11ytable)",
"my_wb <- aftables::generate_workbook(my_aftable)",
"\n\n",
"# Create output",
"\n\n",
Expand All @@ -41,16 +41,16 @@ at_template_workflow <- function() {

}

#' A String Containing Code to Prepare Tables for an 'a11ytables' Object
#' A String Containing Code to Prepare Tables for an 'aftables' Object
#' @noRd
string_tables <- function() {

'cover_list <- list(
"Section 1" = c("First row of Section 1.", "Second row of Section 1."),
"Section 2" = "The only row of Section 2.",
"Section 3" = c(
"[Website](https://best-practice-and-impact.github.io/a11ytables/)",
"[Email address](mailto:fake.address@a11ytables.com)"
"[Website](https://best-practice-and-impact.github.io/aftables/)",
"[Email address](mailto:fake.address@aftables.com)"
)
)
Expand Down Expand Up @@ -85,16 +85,16 @@ table_2_df <- data.frame(Category = LETTERS[1:10], Numeric = 1:10)'

}

#' A String Containing Code to Generate an 'a11ytables' Object
#' A String Containing Code to Generate an 'aftables' Object
#' @noRd
string_create_a11ytable <- function() {
string_create_aftable <- function() {

'my_a11ytable <-
a11ytables::create_a11ytable(
'my_aftable <-
aftables::create_aftable(
tab_titles = c("Cover", "Contents", "Notes", "Table_1", "Table_2"),
sheet_types = c("cover", "contents", "notes", "tables", "tables"),
sheet_titles = c(
"The \'a11ytables\' Demo Workbook",
"The \'aftables\' Demo Workbook",
"Table of contents",
"Notes",
"Table 1: First Example Sheet",
Expand All @@ -111,13 +111,13 @@ string_create_a11ytable <- function() {
NA_character_,
c(
"First custom row for Table 1.",
"A second custom row [with a hyperlink.](https://best-practice-and-impact.github.io/a11ytables/)"
"A second custom row [with a hyperlink.](https://best-practice-and-impact.github.io/aftables/)"
),
"A custom row for Table 2"
),
sources = c(
rep(NA_character_, 3),
"[The Source Material, 2024](https://best-practice-and-impact.github.io/a11ytables/)",
"[The Source Material, 2024](https://best-practice-and-impact.github.io/aftables/)",
"The Source Material, 2024"
),
tables = list(cover_list, contents_df, notes_df, table_1_df, table_2_df)
Expand Down
84 changes: 42 additions & 42 deletions R/a11ytable.R → R/aftable.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#' Create An 'a11ytable' Object
#' Create An 'aftable' Object
#'
#' Create a new a11ytable-class object, which is a special data.frame that
#' Create a new aftable-class object, which is a special data.frame that
#' contains all the information needed in your output spreadsheet. In turn, the
#' object created by this function can be used to populate an 'openxlsx'
#' Workbook-class object with the function \code{\link{generate_workbook}}.
Expand Down Expand Up @@ -79,7 +79,7 @@
#' \item To the 'source' argument for sheets of type 'table' only.
#' }
#'
#' @return An object with classes 'a11ytable', 'tbl' and 'data.frame'.
#' @return An object with classes 'aftable', 'tbl' and 'data.frame'.
#'
#' @examples
#' # Prepare some demo tables of information
Expand All @@ -90,8 +90,8 @@
#' "Section 1" = c("First row of Section 1.", "Second row of Section 1."),
#' "Section 2" = "The only row of Section 2.",
#' "Section 3" = c(
#' "[Website](https://best-practice-and-impact.github.io/a11ytables/)",
#' "[Email address](mailto:fake.address@a11ytables.com)"
#' "[Website](https://best-practice-and-impact.github.io/aftables/)",
#' "[Email address](mailto:fake.address@aftables.com)"
#' )
#' )
#'
Expand Down Expand Up @@ -124,14 +124,14 @@
#'
#' table_2_df <- data.frame(Category = LETTERS[1:10], Numeric = 1:10)
#'
#' # Create 'a11ytables' object
#' # Create 'aftables' object
#'
#' x <-
#' a11ytables::create_a11ytable(
#' aftables::create_aftable(
#' tab_titles = c("Cover", "Contents", "Notes", "Table_1", "Table_2"),
#' sheet_types = c("cover", "contents", "notes", "tables", "tables"),
#' sheet_titles = c(
#' "The 'a11ytables' Demo Workbook",
#' "The 'aftables' Demo Workbook",
#' "Table of contents",
#' "Notes",
#' "Table 1: First Example Sheet",
Expand All @@ -147,27 +147,27 @@
#' NA_character_,
#' "A custom row.",
#' c(
#' "First custom row [with a hyperlink.](https://best-practice-and-impact.github.io/a11ytables/)",
#' "First custom row [with a hyperlink.](https://best-practice-and-impact.github.io/aftables/)",
#' "Second custom row."
#' ),
#' "A custom row."
#' ),
#' sources = c(
#' rep(NA_character_, 3),
#' "[The Source Material, 2024.](https://best-practice-and-impact.github.io/a11ytables/)",
#' "[The Source Material, 2024.](https://best-practice-and-impact.github.io/aftables/)",
#' "The Source Material, 2024."
#' ),
#' tables = list(cover_list, contents_df, notes_df, table_1_df, table_2_df)
#' )
#'
#' # Test that 'a11ytable' is one of the object's classes
#' is_a11ytable(x)
#' # Test that 'aftable' is one of the object's classes
#' is_aftable(x)
#'
#' # Look at the structure of the object
#' str(x, max.level = 2)
#'
#' @export
create_a11ytable <- function(tab_titles,
create_aftable <- function(tab_titles,
sheet_types = c("cover", "contents", "notes", "tables"),

Check warning on line 171 in R/aftable.R

View workflow job for this annotation

GitHub Actions / lint

file=R/aftable.R,line=171,col=29,[indentation_linter] Hanging indent should be 27 spaces but is 29 spaces.
sheet_titles,
blank_cells = NA_character_,
Expand All @@ -187,25 +187,25 @@ create_a11ytable <- function(tab_titles,
x[["custom_rows"]] <- custom_rows
x[["table"]] <- tables

as_a11ytable(x)
as_aftable(x)

}

#' Coerce To An 'a11ytable' Object
#' Coerce To An 'aftable' Object
#'
#' Functions to check if an object is an a11ytable, or coerce it if possible.
#' Functions to check if an object is an aftable, or coerce it if possible.
#'
#' @param x A data.frame object to coerce.
#'
#' @return \code{as_a11ytable} returns an object of class a11ytable if possible.
#' \code{is_a11ytable} returns \code{TRUE} if the object has class
#' a11ytable, otherwise \code{FALSE}.
#' @return \code{as_aftable} returns an object of class aftable if possible.
#' \code{is_aftable} returns \code{TRUE} if the object has class
#' aftable, otherwise \code{FALSE}.
#'
#' @examples
#' is_a11ytable(demo_a11ytable)
#' is_aftable(demo_aftable)
#'
#' @export
as_a11ytable <- function(x) {
as_aftable <- function(x) {

if (any(names(x) %in% "tab_title")) {
.check_tab_titles(x[["tab_title"]])
Expand All @@ -216,41 +216,41 @@ as_a11ytable <- function(x) {
x[["blank_cells"]] <- .append_period(x[["blank_cells"]])
}

class(x) <- c("a11ytable", "tbl", "data.frame")
class(x) <- c("aftable", "tbl", "data.frame")

.validate_a11ytable(x)
.warn_a11ytable(x)
.validate_aftable(x)
.warn_aftable(x)

x

}

#' @rdname as_a11ytable
#' @rdname as_aftable
#' @export
is_a11ytable <- function(x) {
is_aftable <- function(x) {

inherits(x, "a11ytable")
inherits(x, "aftable")

}

#' Summarise An 'a11ytable' Object
#' Summarise An 'aftable' Object
#'
#' A concise result summary of an a11ytable-class object to see information
#' A concise result summary of an aftable-class object to see information
#' about the sheet content. Shows a numbered list of sheets with each tab title,
#' sheet type and table dimensions.
#'
#' @param object An a11ytable-class object for which to get a summary.
#' @param object An aftable-class object for which to get a summary.
#' @param ... Other arguments to pass.
#'
#' @examples
#' # Print a concise summary of the a11ytable-class object
#' summary(demo_a11ytable)
#' # Print a concise summary of the aftable-class object
#' summary(demo_aftable)
#'
#' # Alternatively, look at the structure
#' str(demo_a11ytable, max.level = 2)
#' str(demo_aftable, max.level = 2)
#'
#' @export
summary.a11ytable <- function(object, ...) {
summary.aftable <- function(object, ...) {

tables <- object[["table"]]

Expand Down Expand Up @@ -288,38 +288,38 @@ summary.a11ytable <- function(object, ...) {
)
)

cat("# An a11ytable with", nrow(object), "sheets:", summary_string)
cat("# An aftable with", nrow(object), "sheets:", summary_string)

invisible(object)

}


#' Provide A Succinct Summary Of An 'a11ytable' Object
#' Provide A Succinct Summary Of An 'aftable' Object
#'
#' A brief text description of an a11ytable-class object.
#' A brief text description of an aftable-class object.
#'
#' @param x An a11ytable-class object to summarise.
#' @param x An aftable-class object to summarise.
#' @param ... Other arguments to pass.
#'
#' @return Named character vector.
#'
#' @examples
#' # Print with description
#' print(demo_a11ytable)
#' print(demo_aftable)
#'
#' # Print description only (package 'tibble' must be installed)
#' tibble::tbl_sum(demo_a11ytable)
#' tibble::tbl_sum(demo_aftable)
#'
#' @export
tbl_sum.a11ytable <- function(x, ...) {
tbl_sum.aftable <- function(x, ...) {

header <- sprintf(
"%s x %s",
formatC(nrow(x), big.mark = ","),
formatC(ncol(x), big.mark = ",")
)

c("a11ytable" = header)
c("aftable" = header)

}
File renamed without changes.
Loading

0 comments on commit 49ae3bd

Please sign in to comment.