diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 88193bf..e712a21 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,21 +1,19 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. +# 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 # -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: R-CMD-check +permissions: read-all + jobs: R-CMD-check: runs-on: ${{ matrix.config.os }} @@ -26,80 +24,40 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: '3.6'} - - {os: ubuntu-16.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} + + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - 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-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/R/readGT3X.R b/R/readGT3X.R index 450b82a..14b2497 100644 --- a/R/readGT3X.R +++ b/R/readGT3X.R @@ -284,7 +284,7 @@ read.gt3x <- function(path, verbose = FALSE, asDataFrame = FALSE, accdata <- structure(accdata, - class = c("activity", class(accdata))) + class = unique(c("activity", class(accdata)))) if (asDataFrame) accdata <- as.data.frame(accdata, verbose = verbose > 1) @@ -383,7 +383,7 @@ as.data.frame.activity <- function(x, ..., verbose = FALSE, message("Done") } x <- structure(x, - class = c("activity_df", class(x)), + class = unique(c("activity_df", class(x))), subject_name = all_attributes[["subject_name"]], time_zone = all_attributes[["time_zone"]], missingness = all_attributes[["missingness"]]) @@ -416,9 +416,8 @@ as.data.frame.activity <- function(x, ..., verbose = FALSE, #' @rdname print print.activity_df <- function(x, ...) { - old <- options() # code line i - on.exit(options(old)) # code line i+1 - options(digits = 15L, digits.secs = 3L) + old <- options(digits = 15L, digits.secs = 3L) # code line i + on.exit(options(old)) # code line i+1 arglist <- list(...) if(! "n" %in% names(arglist)) { @@ -436,6 +435,8 @@ print.activity_df <- function(x, ...) { #' @rdname print #' @export head.activity_df <- function(x, ...) { + old <- options(digits = 15L, digits.secs = 3L) # code line i + on.exit(options(old)) # code line i+1 all_attr <- attributes(x) nattr <- names(all_attr) nattr <- setdiff(nattr, c("dim", "dimnames", "names", "rownames")) @@ -444,7 +445,7 @@ head.activity_df <- function(x, ...) { for (iattr in nattr) { attr(x, iattr) <- all_attr[[iattr]] } - class(x) <- c("activity_df", class(x)) + class(x) <- unique(c("activity_df", class(x))) attr(x, "n_head") <- get_n_head(...) x @@ -453,6 +454,8 @@ head.activity_df <- function(x, ...) { #' @rdname print #' @export print.activity <- function(x, ...) { + old <- options(digits = 15L, digits.secs = 3L) # code line i + on.exit(options(old)) # code line i+1 arglist <- list(...) if(! "n" %in% names(arglist)) { @@ -471,6 +474,9 @@ print.activity <- function(x, ...) { #' @importFrom utils head #' @export head.activity <- function(x, ...) { + old <- options(digits = 15L, digits.secs = 3L) # code line i + on.exit(options(old)) # code line i+1 + all_attr <- attributes(x) nattr <- names(all_attr) nattr <- setdiff(nattr, c("dim", "dimnames", "names", "rownames")) @@ -479,7 +485,7 @@ head.activity <- function(x, ...) { for (iattr in nattr) { attr(x, iattr) <- all_attr[[iattr]] } - class(x) <- c("activity", class(x)) + class(x) <- unique(c("activity", class(x))) attr(x, "n_head") <- get_n_head(...) diff --git a/README.Rmd b/README.Rmd index 182b503..0f4f643 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,6 +18,7 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/THLfi/read.gt3x/workflows/R-CMD-check/badge.svg)](https://github.com/THLfi/read.gt3x/actions) [![CRAN status](https://www.r-pkg.org/badges/version/read.gt3x)](https://CRAN.R-project.org/package=read.gt3x) [![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/last-month/read.gt3x?color=blue)](https://r-pkg.org/pkg/read.gt3x) +[![R-CMD-check](https://github.com/THLfi/read.gt3x/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/THLfi/read.gt3x/actions/workflows/R-CMD-check.yaml) The `read.gt3x` R package implements a high performance C++ parser for ActiGraph's `.gt3x` data format. Read the binary accelerometer data (.gt3x) into an R data frame in a few seconds. diff --git a/README.md b/README.md index e486943..d6c4428 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ status](https://www.r-pkg.org/badges/version/read.gt3x)](https://CRAN.R-project.org/package=read.gt3x) [![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/last-month/read.gt3x?color=blue)](https://r-pkg.org/pkg/read.gt3x) +[![R-CMD-check](https://github.com/THLfi/read.gt3x/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/THLfi/read.gt3x/actions/workflows/R-CMD-check.yaml) The `read.gt3x` R package implements a high performance C++ parser for @@ -24,8 +25,7 @@ are used by both individuals and researchers to track movement. The devices measures [proper acceleration](https://en.wikipedia.org/wiki/Proper_acceleration) in three directions: X (right-left), Y (forward-backward), Z (up-down). The -measurement unit is the gravitational unit, -*g* = 9.81*m*/*s*2 +measurement unit is the gravitational unit, $g = 9.81 m / s^2$ Data from the wearable ActiGraph devices is usually extracted and analyzed via a software called *ActiLife*. When data is extracted from @@ -55,9 +55,9 @@ modification is done to the raw data. The package implements an efficient C++ parser which reads activity samples directly from the binary log.bin file inside the .gt3x archive. This allows for -- Storing of the data in original binary format to reserve space -- Fast access to the accelerometer’s measurements -- Circumvent ActiLife’s filtering algorithms +- Storing of the data in original binary format to reserve space +- Fast access to the accelerometer’s measurements +- Circumvent ActiLife’s filtering algorithms ## Installation @@ -110,8 +110,14 @@ head(X) #> [4,] 0.016 -0.012 1.012 #> [5,] 0.016 -0.008 1.008 #> [6,] 0.008 -0.008 1.008 +``` + +``` r head(attributes(X)$time_index) #> [1] 0 1 2 3 4 5 +``` + +``` r attributes(X)[setdiff(names(attributes(X)), c("dim", "dimnames", "time_index"))] #> $missingness #> time n_missing @@ -213,13 +219,16 @@ head(df) #> Sampling Rate: 100Hz #> Firmware Version: 1.7.2 #> Serial Number Prefix: TAS -#> time X Y Z -#> 1 2019-09-17 18:40:00.00 0.000 0.008 0.996 -#> 2 2019-09-17 18:40:00.00 0.016 0.000 1.008 -#> 3 2019-09-17 18:40:00.01 0.020 -0.008 1.004 -#> 4 2019-09-17 18:40:00.02 0.016 -0.012 1.012 -#> 5 2019-09-17 18:40:00.03 0.016 -0.008 1.008 -#> 6 2019-09-17 18:40:00.04 0.008 -0.008 1.008 +#> time X Y Z +#> 1 2019-09-17 18:40:00 0.000 0.008 0.996 +#> 2 2019-09-17 18:40:00 0.016 0.000 1.008 +#> 3 2019-09-17 18:40:00 0.020 -0.008 1.004 +#> 4 2019-09-17 18:40:00 0.016 -0.012 1.012 +#> 5 2019-09-17 18:40:00 0.016 -0.008 1.008 +#> 6 2019-09-17 18:40:00 0.008 -0.008 1.008 +``` + +``` r attributes(df)[setdiff(names(attributes(df)), c("names", "row.names"))] #> $class #> [1] "activity_df" "data.frame"