Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Dev #95

Merged
merged 9 commits into from
Aug 5, 2024
Merged

Dev #95

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
52 changes: 52 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
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
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:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
50 changes: 50 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
61 changes: 61 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
39 changes: 21 additions & 18 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
Type: Package
Package: saros.contents
Title: Semi-Automatic Reporting of Ordinary Surveys
Version: 0.1
Title: Contents for the Semi-Automatic Reporting of Ordinary Surveys (Saros)
Version: 0.1.0
Authors@R: c(
person(given = "Stephan",
family = "Daus",
role = c("aut", "cre", "cph"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-0230-6997")),
person("Julia", "Silge", role = c("ctb"), comment = "Author of internal scale_x_reordered"),
person("David", "Robinson", role = c("ctb"), comment = "Author of internal scale_x_reordered"),
person("Nordic Institute for The Studies of Innovation, Research and Education (NIFU)",
role = c("fnd")),
person("Kristiania University College",
role = c("fnd"))
)
Maintainer: Stephan Daus <[email protected]>
Description: Produces highly customized reports, primarily intended for survey
research. Building on 'Quarto' (<https://quarto.org>), it generates draft
chapters of all specified dependent/independent variables, which can be
further edited by hand, containing figures, tables and analyses (currently
only uni-/bivariate tests of equivalent means/proportions). The feature
'mesos'-reports offer tailor-made batch report production where e.g. an
institution can compare itself to all other participants. Publication tools
are also included, such as password generation for 'mesos'-report sections
on a 'Quarto' Website.
Description: Offers a systematic way for conditional reporting of figures and tables for many
(and bivariate combinations of) variables, typically from survey data.
Contains interactive ggiraph-based
(<https://CRAN.R-project.org/package=ggiraph>) plotting functions and
data frame-based summary tables (bivariate significance tests,
frequencies/proportions, unique open ended responses, etc) with
many arguments for customization, and extensions possible. Uses a global
`options()` system for neatly reducing redundant code.
Also contains tools for immediate saving of objects and returning a hashed link to the object,
useful for creating download links to high resolution images upon rendering in Quarto.
See 'saros' (<https://CRAN.R-project.org/package=saros>) for the main umbrella package.
Note: Free to use for non-Norwegian institutions, otherwise see LICENSE.
License: MIT + file LICENSE
URL: https://nifu-no.github.io/saros.contents/, https://github.com/NIFU-NO/saros.contents
Expand All @@ -31,7 +35,6 @@ Depends:
R (>= 4.2.0)
Imports:
cli,
saros.base,
utils,
vctrs,
glue,
Expand All @@ -41,11 +44,11 @@ Imports:
rlang,
stringi,
forcats,
ggplot2,
ggiraph,
mschart,
officer,
fs
ggplot2,
ggiraph,
mschart,
officer,
fs
Suggests:
covr,
srvyr,
Expand All @@ -58,11 +61,11 @@ Suggests:
withr,
quarto,
spelling
SystemRequirements: Quarto command line tools (https://github.com/quarto-dev/quarto-cli) for the rendering wrapper functionality.
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Language: en-US
Config/Needs/website: rmarkdown
Config/testthat/parallel: true
LazyData: true
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# saros.contents 0.1.0

* Initial CRAN submission.
4 changes: 2 additions & 2 deletions R/colour.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ get_colour_set <-
#' @return A colour set as character vector, where `NA` has the `colour_na`, and the rest are taken from colour_palette_nominal if available.
#' @keywords internal
#'
# get_colour_palette(saros.base::ex_survey, col_pos=c("b_1", "b_2"))
# get_colour_palette(saros.base::ex_survey, col_pos=c("b_1", "b_2"),
# get_colour_palette(ex_survey, col_pos=c("b_1", "b_2"))
# get_colour_palette(ex_survey, col_pos=c("b_1", "b_2"),
# colour_palette_nominal = c("red", "blue", "orange"))
get_colour_palette <-
function(
Expand Down
14 changes: 7 additions & 7 deletions R/crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ crosstable.data.frame <-
}

# indep_names <- colnames(data[, indep, drop = FALSE])
indep_labels <- saros.base::get_raw_labels(data = data, col_pos = indep)
indep_labels <- get_raw_labels(data = data, col_pos = indep)
col_names <- colnames(data[ , dep, drop=FALSE])[!(colnames(data[ , dep, drop=FALSE]) %in% indep)]


Expand Down Expand Up @@ -147,7 +147,7 @@ crosstable.data.frame <-
levels = fct_lvls,
labels = fct_lvls,
exclude = character())
summary_prop$.variable_label <- unname(saros.base::get_raw_labels(data = data, col_pos = .x))
summary_prop$.variable_label <- unname(get_raw_labels(data = data, col_pos = .x))
# summary_prop$.mean_base <- as.integer(summary_prop$.category) * summary_prop$.count
summary_prop$.count_se <- NA_real_
summary_prop$.proportion_se <- NA_real_
Expand All @@ -168,7 +168,7 @@ crosstable.data.frame <-
out$.variable_name <- .x
} else {
out <- data.frame(.variable_name = .x,
.variable_label = unname(saros.base::get_raw_labels(data = data, col_pos = .x)),
.variable_label = unname(get_raw_labels(data = data, col_pos = .x)),
.category = factor(NA),
.count = NA_integer_,
.count_se = NA_real_,
Expand Down Expand Up @@ -230,7 +230,7 @@ crosstable.tbl_svy <-
showNA <- rlang::arg_match(showNA, values = eval(formals(makeme)$showNA), error_call = call)

# indep_names <- colnames(data[, indep, drop = FALSE])
indep_labels <- saros.base::get_raw_labels(data = data$variables, col_pos = indep)
indep_labels <- get_raw_labels(data = data$variables, col_pos = indep)
col_names <- colnames(data[, dep, drop = FALSE])[!(colnames(data[, dep, drop = FALSE]) %in% indep)]

# indep_names <- colnames(srvyr::select(data, indep))
Expand Down Expand Up @@ -286,10 +286,10 @@ crosstable.tbl_svy <-
.proportion = srvyr::survey_prop(proportion = TRUE))
summary_prop <- srvyr::ungroup(summary_prop)
summary_prop <- srvyr::as_tibble(summary_prop)
# print(saros.base::get_raw_labels(data = srvyr::as_tibble(data), col_pos = .x))
# print(get_raw_labels(data = srvyr::as_tibble(data), col_pos = .x))
summary_prop <- dplyr::mutate(summary_prop,
.category = factor(x = .data$.category, levels = fct_lvls, labels = fct_lvls),
.variable_label = saros.base::get_raw_labels(data = srvyr::as_tibble(data), col_pos = .x)
.variable_label = get_raw_labels(data = srvyr::as_tibble(data), col_pos = .x)
# .mean_base = as.integer(.category) * .count
)

Expand All @@ -302,7 +302,7 @@ crosstable.tbl_svy <-

} else {
out <- data.frame(.variable_name = .x,
.variable_label = unname(saros.base::get_raw_labels(data = data, col_pos = .x)),
.variable_label = unname(get_raw_labels(data = data, col_pos = .x)),
.category = factor(NA),
.count = NA_integer_,
.count_total = NA_integer_,
Expand Down
58 changes: 58 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# #' @inherit saros.base::ex_survey description source references title
# #' @export
# ex_survey <- saros.base::ex_survey

#.not_used_fns <- function() {
# saros.base::read_default_draft_report_args
#}

#' ex_survey: Mockup dataset of a survey.
#'
#' A dataset containing fake respondents' answers to survey questions.
#' The first two, x_sex and x_human, are intended to be independent variables,
#' whereas the remaining are dependent. The underscore _ in variable names
#' separates item groups (prefix) from items (suffix) (i.e. a_1-a_9 => a + 1-9),
#' whereas ' - ' separates the same for labels.
#' The latter corresponds with the default in SurveyXact.
#'
#' @format A data frame with 100 rows and 29 variables:
#' \describe{
#' \item{x1_sex}{Gender}
#' \item{x2_human}{Is respondent human?}
#' \item{x3_nationality}{Where is the respondent born?}
#' \item{a_1}{Do you consent to the following? - Agreement #1}
#' \item{a_2}{Do you consent to the following? - Agreement #2}
#' \item{a_3}{Do you consent to the following? - Agreement #3}
#' \item{a_4}{Do you consent to the following? - Agreement #4}
#' \item{a_5}{Do you consent to the following? - Agreement #5}
#' \item{a_6}{Do you consent to the following? - Agreement #6}
#' \item{a_7}{Do you consent to the following? - Agreement #7}
#' \item{a_8}{Do you consent to the following? - Agreement #8}
#' \item{a_9}{Do you consent to the following? - Agreement #9}
#' \item{b_1}{How much do you like living in - Beijing}
#' \item{b_2}{How much do you like living in - Brussels}
#' \item{b_3}{How much do you like living in - Budapest}
#' \item{c_1}{How many years of experience do you have in - Company A}
#' \item{c_2}{How many years of experience do you have in - Company B}
#' \item{d_1}{Rate your degree of confidence doing the following - Driving}
#' \item{d_2}{Rate your degree of confidence doing the following - Drinking}
#' \item{d_3}{Rate your degree of confidence doing the following - Driving}
#' \item{d_4}{Rate your degree of confidence doing the following - Dancing}
#' \item{e_1}{How often do you do the following? - Eat}
#' \item{e_2}{How often do you do the following? - Eavesdrop}
#' \item{e_3}{How often do you do the following? - Exercise}
#' \item{e_4}{How often do you do the following? - Encourage someone whom you have only recently met and who struggles with simple tasks that they cannot achieve by themselves}
#' \item{p_1}{To what extent do you agree or disagree to the
#' following policies - Red Party}
#' \item{p_2}{To what extent do you agree or disagree to the
#' following policies - Green Party}
#' \item{p_3}{To what extent do you agree or disagree to the
#' following policies - Yellow Party}
#' \item{p_4}{To what extent do you agree or disagree to the
#' following policies - Blue Party}
#' \item{f_uni}{Which of the following universities would you
#' prefer to study at?}
#' \item{open_comments}{Do you have any comments to the survey?}
#' \item{resp_status}{Response status}
#' }
"ex_survey"
Loading