Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3ac8005
doc: tidy up documentation
martinctc Jul 21, 2023
c3927b3
docs: update DESCRIPTION
martinctc Jul 21, 2023
6cb8d4d
docs: update documentation
martinctc Jul 24, 2023
a7bb775
feat: add test_catcat
martinctc Nov 3, 2023
309d774
feat: add `create_freq_dist()`
martinctc Oct 1, 2024
56e2d03
doc: add examples
martinctc Oct 1, 2024
80fc67b
fix: resolve R CMD check issues
martinctc Oct 1, 2024
ccb2c7c
chore: update docs
martinctc Oct 1, 2024
a7603e6
Merge branch 'master' into release/first-cran-release
martinctc Jun 20, 2025
1abee11
test: add comprehensive unit tests for various functions
martinctc Jun 20, 2025
dc261d8
chore: update roxygen
martinctc Jun 20, 2025
48b00b6
test: improve tests for set_varl and squish functions
martinctc Jun 20, 2025
c1cf1d0
feat: add vignette and getting started Rmd
martinctc Jun 20, 2025
ac5faf1
fix: R CMD check issues with vignette
martinctc Jun 20, 2025
217e0c3
test: add comprehensive unit tests
martinctc Jan 27, 2026
929df30
chore: update NAMESPACE and documentation; enhance split_tt function …
martinctc Jan 27, 2026
b6e5b8a
chore: streamline R-CMD-check workflow by removing manual dependency …
martinctc Jan 27, 2026
e23b8cb
chore: simplify R-CMD-check workflow by consolidating dependency inst…
martinctc Jan 27, 2026
6bd8586
chore: prepare for CRAN submission; update DESCRIPTION, add LICENSE a…
martinctc Jan 28, 2026
cbe5438
docs: improve documentation
martinctc Jan 28, 2026
52e9d25
chore: enhance R-CMD-check workflow with matrix strategy for OS and R…
martinctc Jan 28, 2026
75131e7
chore: update NEWS.md to reflect version 0.1.0 release
martinctc Jan 28, 2026
1d25e25
chore: fix inconsistent indentation
martinctc Jan 29, 2026
2002c3f
Merge branch 'release/first-cran-release' of https://github.com/marti…
martinctc Jan 29, 2026
e4d9398
docs: improve documentation for calc_pc_loglin function and its Rd file
martinctc Jan 29, 2026
298a3ad
feat: add R-hub GitHub Actions workflow for automated checks
martinctc Jan 29, 2026
cef9c9a
fix: update DESCRIPTION for British English spelling and add Language…
martinctc Jan 29, 2026
8d4f8fa
docs: simplify NEWS.md
martinctc Jan 29, 2026
8c6d74c
chore: add CRAN-SUBMISSION file and update .Rbuildignore to include it
martinctc Jan 29, 2026
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
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
^icons$
^_development$
^\.github$
^_pkgdown.yml$
^doc$
^Meta$
^cran-comments\.md$
^LICENSE\.md$
^CRAN-SUBMISSION$
53 changes: 41 additions & 12 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
on: [push, pull_request]
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: macOS-latest
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
- name: Check
env:
_R_CHECK_FORCE_SUGGESTS_: true
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-manual", "--as-cran")'
error-on: '"error"'
upload-snapshots: true
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.Rhistory
.RData
.Ruserdata
/doc/
/Meta/
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.1.0
Date: 2026-01-29 11:16:50 UTC
SHA: 8d4f8fa0882caebdbb24a1f3f25c7feda620ce9d
36 changes: 26 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
Package: surveytoolbox
Type: Package
Title: Useful Support Functions for Survey Analysis
Version: 0.1.0.9000
Author: Martin Chan
Maintainer: Martin Chan <martinchan53@gmail.com>
URL: https://github.com/martinctc/surveytoolbox
Description: A R package containing useful support functions for survey analysis.
Version: 0.1.0
Authors@R:
person("Martin", "Chan", , "martinchan53@gmail.com", role = c("aut", "cre"))
URL: https://github.com/martinctc/surveytoolbox/
BugReports: https://github.com/martinctc/surveytoolbox/issues
Description: A collection of tools for analysing and visualising survey data
in R. This package provides functions for manipulating variable and value
labels commonly found in SPSS datasets, creating data dictionaries,
converting variable types between labelled and standard R types, performing
rowwise operations with 'dplyr' syntax, creating dummy variables from
categorical data, and computing common survey metrics such as Net Promoter
Score (NPS) and top-box/bottom-box transformations. It integrates seamlessly
with the 'tidyverse' workflow and the 'haven' package for labelled data.
License: GPL-3
Encoding: UTF-8
Language: en-GB
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Imports:
base,
dplyr,
stringr,
stats,
Expand All @@ -21,11 +29,19 @@ Imports:
readr,
haven,
tidyr,
psych,
magrittr,
purrr,
glue,
data.table
data.table,
broom,
rstatix,
graphics,
rlang
Suggests:
testthat (>= 3.0.0)
testthat (>= 3.0.0),
knitr,
rmarkdown,
ggplot2,
psych
Config/testthat/edition: 3
VignetteBuilder: knitr
5 changes: 5 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# GNU General Public License v3.0

This package is licensed under the GNU General Public License version 3 (GPL-3).

For the full text of the license, see: https://www.gnu.org/licenses/gpl-3.0.en.html
13 changes: 13 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export(chr_to_var)
export(clean_strings)
export(copy_df)
export(cor_to_df)
export(create_freq_dist)
export(create_named_list)
export(data_dict)
export(extract_fa_loads)
Expand All @@ -40,19 +41,31 @@ export(squish)
export(superspread)
export(superspread_count)
export(superspread_fill)
export(test_chisq)
export(timed_fn)
export(ttest_nps)
export(varl_tb)
export(wrap_text)
import(dplyr)
import(haven)
import(stringr)
importFrom(broom,tidy)
importFrom(data.table,":=")
importFrom(dplyr,filter)
importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(glue,glue)
importFrom(graphics,hist)
importFrom(magrittr,"%>%")
importFrom(purrr,is_null)
importFrom(purrr,map)
importFrom(rlang,.data)
importFrom(rlang,sym)
importFrom(rstatix,chisq_test)
importFrom(stats,chisq.test)
importFrom(stats,fisher.test)
importFrom(tibble,enframe)
importFrom(tibble,tibble)
importFrom(tidyr,drop_na)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,unnest)
16 changes: 16 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# surveytoolbox 0.1.0

* Initial CRAN release
* Core functions for survey data manipulation:
- `superspread()`, `superspread_count()`, `superspread_fill()` for creating dummy variables
- `data_dict()` for creating data dictionaries from labelled data
- `look_up()` for lookup table operations
- `apply_row()` for rowwise operations with dplyr syntax
- `box_it()` for creating top/bottom box variables
- `as_nps()` and `as_nps_cat()` for NPS calculations
- `test_chisq()` and `ttest_nps()` for statistical tests
- Label manipulation functions: `set_varl()`, `set_vall()`, `recode_vallab()`, `extract_vallab()`
- Data conversion functions: `char_to_lab()`, `lab_to_char()`, `chr_to_var()`
- Utility functions: `clean_strings()`, `wrap_text()`, `timed_fn()`, `categorise()`
- File operations: `sav_to_rds()`, `copy_df()`, `read_df()`
- Scale transformations: `likert_convert()`, `likert_reverse()`, `maxmin()`
6 changes: 4 additions & 2 deletions R/CAGR.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#' Calculate CAGR
#' @title Calculate CAGR
#'
#' Calculates the Compound Annual Growth Rate (CAGR).
#' @description Compute the Compound Annual Growth Rate (CAGR).
#' @param value_begin The value at the start of the series.
#' @param value_end The value at the end of the series.
#' @param n_periods The number of periods to base the CAGR calculations on.
#'
#' @seealso http://www.investopedia.com/terms/c/cagr.asp
#'
#' @return numeric value
#'
#' @export
CAGR <- function(value_begin, value_end, n_periods){

Expand Down
23 changes: 14 additions & 9 deletions R/any_x.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#' @title Function that returns TRUE/FALSE if value exists in x, but returns NA if x consists entirely of NAs
#' @title Function that returns either TRUE or FALSE if value exists in x, but
#' returns NA if x consists entirely of NAs
#'
#' @description
#' A more nuanced response is returned than the standard R method,
#' which does not return NAs if x is all NAs.
#' Has useful applications in understanding a set of categorical variables
#' belonging to a single question.
#' E.g. A question on brand usage across 10 product types to understand 'any' usage of a brand x.
#'
#' @return A logical vector whether a value exists in x, and returns NA if x contains only NAs.
#' A more nuanced response is returned than the standard R method, which does
#' not return NAs if x is all NAs. Has useful applications in understanding a
#' set of categorical variables belonging to a single question.
#' E.g. A question on brand usage across 10 product types to understand 'any'
#' usage of a brand x.
#'
#' @param x Vector of values to test.
#' @param value Value to test whether it exists in x. NA is returned if none exists at all.
#' @param value Value to test whether it exists in x. NA is returned if none
#' exists at all.
#'
#' @examples
#' any_x(c(1,0,1),1) # TRUE
#' any_x(c(1,NA,1),1) # TRUE
#' any_x(c(0,0,NA),1) # FALSE
#' any_x(c(NA,NA,NA),1) # NA
#'
#' @return A logical vector whether a value exists in x, and returns NA if x
#' contains only NAs.
#'
#' @export
any_x <- function(x, value){
if(all(is.na(x))){
Expand Down
10 changes: 6 additions & 4 deletions R/append_to_list.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#' @title Append an item to a list dynamically
#'
#' @description
#' The `append_to_list()` function appends an object to the specified list in Global Environment (default).
#' This function is pipe-optimised, and allows the option of specifying a name for the new object in the list.
#' The `append_to_list()` function appends an object to the specified list in
#' Global Environment (default). This function is pipe-optimised, and allows the
#' option of specifying a name for the new object in the list.
#'
#' @param x An object to append to list, e.g. vector, data frame.
#' @param list_x Target list to append object to.
#' @param name Specify a character string for the name of the list. Defaults to blank
#' @param name character string for the name of the list. Defaults to
#' a blank string
#' @param enviro Specifies the environment
#'
#' @examples
#' a_list <- list(NULL)
#' append_to_list(iris,a_list,"iris")
#'
#' @export
append_to_list <- function(x, list_x, name="", enviro = .GlobalEnv){
append_to_list <- function(x, list_x, name = "", enviro = .GlobalEnv){

temp <- deparse(substitute(list_x))

Expand Down
Loading