mirror of
https://github.com/agdamsbo/REDCapCAST.git
synced 2025-04-01 21:52:32 +02:00
Compare commits
3 Commits
3eea26223b
...
f91aed0948
Author | SHA1 | Date | |
---|---|---|---|
f91aed0948 | |||
319ccfd9dd | |||
7dfbb9b549 |
30
.github/workflows/test-coverage.yaml
vendored
30
.github/workflows/test-coverage.yaml
vendored
@ -4,9 +4,10 @@ on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
|
||||
name: test-coverage
|
||||
name: test-coverage.yaml
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
test-coverage:
|
||||
@ -15,38 +16,47 @@ jobs:
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: r-lib/actions/setup-r@v2
|
||||
with:
|
||||
use-public-rspm: true
|
||||
|
||||
# - uses: r-lib/actions/setup-renv@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
extra-packages: any::covr
|
||||
extra-packages: any::covr, any::xml2
|
||||
needs: coverage
|
||||
|
||||
- name: Test coverage
|
||||
run: |
|
||||
covr::codecov(
|
||||
cov <- covr::package_coverage(
|
||||
quiet = FALSE,
|
||||
clean = FALSE,
|
||||
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
|
||||
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
|
||||
)
|
||||
print(cov)
|
||||
covr::to_cobertura(cov)
|
||||
shell: Rscript {0}
|
||||
|
||||
- uses: codecov/codecov-action@v4
|
||||
with:
|
||||
# Fail if error if not on PR, or if on PR and token is given
|
||||
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
|
||||
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
|
||||
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
|
||||
shell: bash
|
||||
|
||||
- name: Upload test results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-test-failures
|
||||
path: ${{ runner.temp }}/package
|
||||
|
@ -1,6 +1,6 @@
|
||||
Package: REDCapCAST
|
||||
Title: REDCap Metadata Casting and Castellated Data Handling
|
||||
Version: 25.1.1
|
||||
Version: 25.2.1
|
||||
Authors@R: c(
|
||||
person("Andreas Gammelgaard", "Damsbo", email = "agdamsbo@clin.au.dk",
|
||||
role = c("aut", "cre"),comment = c(ORCID = "0000-0002-7559-1154")),
|
||||
|
4
NEWS.md
4
NEWS.md
@ -1,3 +1,7 @@
|
||||
# REDCapCAST 25.2.1
|
||||
|
||||
* FIX: `as_factor()` now interprets empty variables with empty levels attribute as logicals to avoid returning factors with empty levels.
|
||||
|
||||
# REDCapCAST 25.1.1
|
||||
|
||||
The newly introduced extension of `forcats::fct_drop()` has been corrected to work as intended as a method.
|
||||
|
@ -7,6 +7,8 @@
|
||||
#' Please refer to parent functions for extended documentation.
|
||||
#' To avoid redundancy calls and errors, functions are copy-pasted here
|
||||
#'
|
||||
#' Empty variables with empty levels attribute are interpreted as logicals
|
||||
#'
|
||||
#' @param x Object to coerce to a factor.
|
||||
#' @param ... Other arguments passed down to method.
|
||||
#' @param only_labelled Only apply to labelled columns?
|
||||
@ -24,7 +26,14 @@
|
||||
#' labels = c(Unknown = 9, Refused = 10),
|
||||
#' class = "haven_labelled"
|
||||
#' ) |>
|
||||
#' as_factor()
|
||||
#' as_factor() |> class()
|
||||
#' structure(rep(NA,10),
|
||||
#' class = c("labelled")
|
||||
#' ) |>
|
||||
#' as_factor() |> summary()
|
||||
#'
|
||||
#' rep(NA,10) |> as_factor()
|
||||
#'
|
||||
#' @importFrom forcats as_factor
|
||||
#' @export
|
||||
#' @name as_factor
|
||||
@ -46,8 +55,6 @@ as_factor.logical <- function(x, ...) {
|
||||
set_attr(x, labels, overwrite = FALSE)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' @rdname as_factor
|
||||
#' @export
|
||||
as_factor.numeric <- function(x, ...) {
|
||||
@ -121,7 +128,13 @@ as_factor.haven_labelled <- function(x, levels = c("default", "labels", "values"
|
||||
|
||||
x <- structure(x, label = label)
|
||||
|
||||
set_attr(x, labels_all, overwrite = FALSE)
|
||||
out <- set_attr(x, labels_all, overwrite = FALSE)
|
||||
|
||||
if (all_na(out) & length(levels(out))==0){
|
||||
as_factor.logical(out)
|
||||
} else {
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
#' @export
|
||||
|
@ -1,7 +1,6 @@
|
||||
<!-- badges: start -->
|
||||
|
||||
[](https://github.com/agdamsbo/REDCapCAST) [](https://CRAN.R-project.org/package=REDCapCAST) [](https://doi.org/10.5281/zenodo.8013984) [](https://github.com/agdamsbo/REDCapCAST/actions/workflows/rhub.yaml) [](https://github.com/agdamsbo/REDCapCAST/actions/workflows/R-CMD-check.yaml) [](https://github.com/agdamsbo/REDCapCAST/actions/workflows/pages/pages-build-deployment) [](https://app.codecov.io/gh/agdamsbo/REDCapCAST?branch=master) [](https://cran.r-project.org/package=REDCapCAST) [](https://lifecycle.r-lib.org/articles/stages.html)
|
||||
|
||||
[](https://github.com/agdamsbo/REDCapCAST) [](https://CRAN.R-project.org/package=REDCapCAST) [](https://doi.org/10.5281/zenodo.8013984) [](https://github.com/agdamsbo/REDCapCAST/actions/workflows/rhub.yaml) [](https://github.com/agdamsbo/REDCapCAST/actions/workflows/R-CMD-check.yaml) [](https://github.com/agdamsbo/REDCapCAST/actions/workflows/pages/pages-build-deployment) [](https://cran.r-project.org/package=REDCapCAST) [](https://lifecycle.r-lib.org/articles/stages.html) [](https://app.codecov.io/gh/agdamsbo/REDCapCAST)
|
||||
<!-- badges: end -->
|
||||
|
||||
# REDCapCAST package <img src="man/figures/logo.png" align="right"/>
|
||||
|
@ -63,6 +63,8 @@ ta loss in case of rich formatted and labelled data.
|
||||
\details{
|
||||
Please refer to parent functions for extended documentation.
|
||||
To avoid redundancy calls and errors, functions are copy-pasted here
|
||||
|
||||
Empty variables with empty levels attribute are interpreted as logicals
|
||||
}
|
||||
\examples{
|
||||
# will preserve all attributes
|
||||
@ -77,5 +79,12 @@ structure(c(1, 2, 3, 2, 10, 9),
|
||||
labels = c(Unknown = 9, Refused = 10),
|
||||
class = "haven_labelled"
|
||||
) |>
|
||||
as_factor()
|
||||
as_factor() |> class()
|
||||
structure(rep(NA,10),
|
||||
class = c("labelled")
|
||||
) |>
|
||||
as_factor() |> summary()
|
||||
|
||||
rep(NA,10) |> as_factor()
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user