Skip to content

Commit

Permalink
Merge pull request #212 from januarharianto/master
Browse files Browse the repository at this point in the history
sync dev
  • Loading branch information
nicholascarey committed Mar 29, 2024
2 parents f29b884 + 3f47f34 commit 9fbe6ca
Show file tree
Hide file tree
Showing 20 changed files with 616 additions and 125 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
^\.Rproj\.user$ # used for temporary files.
^README\.Rmd$ # An Rmarkdown file used to generate README.md
^cran-comments\.md$ # Comments for CRAN submission
^NEWS\.md$ # A news file written in Markdown
^manuscript$ # Folder that contains the files for the manuscript
^docs$ # Folder that stores HTML vignettes
^doc$ # Folder that stores HTML vignettes
Expand All @@ -13,6 +12,7 @@
^data-raw$
^.DS_Store$
^t5.rda$
cran-comments.md

# Insurance
vignettes
Expand All @@ -24,3 +24,4 @@ vignettes
Changelog
^CITATION\.cff$
^codecov\.yml$
^CRAN-SUBMISSION$
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 2.3.2
Date: 2023-11-16 15:53:23 UTC
SHA: 2cdfcb90c240c379300bf0f55abbb8df2b6a2e5d
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: respR
Type: Package
Title: Import, Process, Analyse, and Calculate Rates from Respirometry Data
Date: 2023-06-04
Version: 2.3.1
Date: 2023-11-16
Version: 2.3.2
Maintainer: Nicholas Carey <nicholascarey@gmail.com>
Authors@R: c(
person(given = "Nicholas",
Expand Down Expand Up @@ -37,7 +37,6 @@ Imports:
magrittr,
marelac,
purrr,
readxl,
roll,
segmented,
stats,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ importFrom(parallel,makeCluster)
importFrom(parallel,parLapply)
importFrom(parallel,stopCluster)
importFrom(purrr,reduce)
importFrom(readxl,read_excel)
importFrom(roll,roll_lm)
importFrom(stats,quantile)
importFrom(stringr,str_replace)
Expand Down
17 changes: 4 additions & 13 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@

<!---
Each version should:
List its release date in the above format.
Group changes to describe their impact on the project, as follows:
Added: for new features.
Changed: for changes in existing functionality.
Deprecated: for once-stable features removed in upcoming releases.
Removed: for deprecated features removed in this release.
Fixed: for any bug fixes.
Security: to invite users to upgrade in case of vulnerabilities.
All version changes go in here now when you make a commit!
--->
## Version 2.3.2 -- 2023-11-15

Minor changes to unit tests and documentation.


## Version 2.3.1 -- 2023-06-05

Expand Down
28 changes: 14 additions & 14 deletions R/auto_rate_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' This is an internal function for `auto_rate()`. Used to validate inputs
#'
#' @param df data.frame object.
#' @param x data.frame object.
#' @param by string.
#' @param method string.
#'
Expand Down Expand Up @@ -424,26 +424,26 @@ static_roll <- function(df, win) {
#' @return a data.table object
#' @keywords internal
#' @import parallel
time_roll <- function(dt, width, parallel = FALSE) {
time_roll <- function(df, width, parallel = FALSE) {
future_lapply <- plan <- NULL # global variables hack (unfortunate)
dt <- data.table::data.table(dt)
data.table::setnames(dt, 1:2, c("V1", "V2"))
df <- data.table::data.table(df)
data.table::setnames(df, 1:2, c("V1", "V2"))

# The cutoff specifies where to stop the rolling regression, based on width
time_cutoff <- max(dt[,1]) - width
row_cutoff <- max(dt[, which(V1 <= time_cutoff)])
time_cutoff <- max(df[,1]) - width
row_cutoff <- max(df[, which(V1 <= time_cutoff)])

# if(parallel) {
# oplan <- plan()
# on.exit(plan(oplan), add = TRUE)
# if (os() == 'win') {
# plan(multicore)
# } else plan(multisession)
# out <- future_lapply(1:row_cutoff, function(x) time_lm(dt,
# dt[[1]][x], dt[[1]][x] + width))
# out <- future_lapply(1:row_cutoff, function(x) time_lm(df,
# df[[1]][x], df[[1]][x] + width))
# } else {
# out <- lapply(1:row_cutoff, function(x) time_lm(dt,
# dt[[1]][x], dt[[1]][x] + width))
# out <- lapply(1:row_cutoff, function(x) time_lm(df,
# df[[1]][x], df[[1]][x] + width))
# }

# parallelisation
Expand All @@ -453,11 +453,11 @@ time_roll <- function(dt, width, parallel = FALSE) {
cl <- parallel::makeCluster(no_cores)
} else cl <- parallel::makeCluster(no_cores, type = "FORK")
parallel::clusterExport(cl, "time_lm")
out <- parallel::parLapply(cl, 1:row_cutoff, function(x) time_lm(dt,
dt[[1]][x], dt[[1]][x] + width))
out <- parallel::parLapply(cl, 1:row_cutoff, function(x) time_lm(df,
df[[1]][x], df[[1]][x] + width))
parallel::stopCluster(cl) # stop cluster (release cores)
} else out <- lapply(1:row_cutoff, function(x) time_lm(dt,
dt[[1]][x], dt[[1]][x] + width))
} else out <- lapply(1:row_cutoff, function(x) time_lm(df,
df[[1]][x], df[[1]][x] + width))

out <- data.table::rbindlist(out)
return(out)
Expand Down
1 change: 0 additions & 1 deletion R/import_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
#' directory, as determined by the `path` parameter.
#'
#' @importFrom data.table data.table fread
#' @importFrom readxl read_excel
#' @importFrom xml2 xml_text
#' @importFrom xml2 read_html
#' @importFrom tools file_path_sans_ext
Expand Down
2 changes: 2 additions & 0 deletions R/inspect.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
#' @export
#'
#' @examples
#' \donttest{
#' ## By default, assumes time is col 1 and oxygen col2:
#' inspect(sardine.rd)
#'
Expand Down Expand Up @@ -222,6 +223,7 @@
#' ## allow better y-axis label visibility
#' inspect(sardine.rd, time = 1, oxygen = 2,
#' las = 1, mai = c(0.3, 0.35, 0.35, 0.15))
#' }

inspect <- function(x, time = NULL, oxygen = NULL,
width = 0.1, plot = TRUE, add.data = NULL, ...) {
Expand Down
4 changes: 0 additions & 4 deletions R/startup.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ Visit this site for help documentation and vignettes:
http://bit.ly/respr_pkg
And follow respR on Twitter for latest news:
http://twitter.com/respr_pkg
======================================================================")

packageStartupMessage(start_msg)
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
[![Github watchers](https://img.shields.io/github/watchers/januarharianto/respR?label=Watch&style=social)](https://img.shields.io/github/watchers/januarharianto/respR?style=social)
[![Github sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&style=social)](https://github.com/sponsors/nicholascarey)
[![Mastodon](https://img.shields.io/badge/dynamic/json?label=Mastodon&query=totalItems&url=https%3A%2F%2Fmas.to%2Fusers%2FrespR%2Ffollowers.json&logo=mastodon&style=social)](https://mas.to/@respR)
[![Twitter](https://img.shields.io/twitter/follow/respR_pkg.svg?label=Follow&style=social)](https://twitter.com/respR_pkg?ref_src=twsrc%5Etfw)

<!-- badges: end -->

Expand Down Expand Up @@ -44,6 +43,12 @@ A highlight of the package is the `auto_rate()` function. This uses machine lear
install.packages("respR")
```

You can also install the latest version direct from [**Github**](https://github.com/januarharianto/respr/):

```r
devtools::install_github("januarharianto/respR")
```

## Getting started

Visit the `respR` [**website**](https://januarharianto.github.io/respR/) to get started. The site has a range of vignettes detailing the functionality, plus example workflows, documentation, and more.
Expand All @@ -56,7 +61,7 @@ We are also happy to help directly. If you have problems using the package or ge

The package has also been [**peer reviewed and published**](https://doi.org/10.1111/2041-210X.13162) in *Methods in Ecology and Evolution*. Please cite this publication if you use `respR` in your published work.

`respR` has been used to examine metabolic rates and photosynthesis in corals, plankton, micro- and macro-algae, fish, crustaceans, echinoderms, cephalopods, bivalves and more, in both lab and field studies. Check the [**respR in use**](https://januarharianto.github.io/respR/articles/citations.html) page to see a list of published studies which have used the package to analyse their data.
`respR` has been used to examine metabolic rates and photosynthesis in corals, plankton, micro- and macro-algae, fish, crustaceans, echinoderms, cephalopods, bivalves and more, in both lab and field studies. Check the [**respR Citations**](https://januarharianto.github.io/respR/articles/citations.html) page to see a list of published studies which have used the package to analyse their data.

 \
 \
Expand All @@ -66,11 +71,11 @@ The package has also been [**peer reviewed and published**](https://doi.org/10.1

See [**here**](https://januarharianto.github.io/respR/articles/contact.html) for more ways of providing feedback and getting in touch if you are having issues.

For the latest news and regular updates from the world of respirometry follow `respR` on **<a rel="me" href="https://mas.to/@respR">Mastodon</a>** or [**Twitter**](https://twitter.com/respR_pkg).
For the latest news and regular updates from the world of respirometry follow `respR` on **<a rel="me" href="https://mas.to/@respR">Mastodon</a>**.

## Support package development

If you would like to help support the package development or just buy us a beer to say thanks see [here](https://januarharianto.github.io/respR/articles/contact.html#support-future-development)
If you would like to help support the package development or just buy us a beer to say thanks see [**here**](https://januarharianto.github.io/respR/articles/contact.html#support-future-development)

## Developers

Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ navbar:
href: articles/contact.html
- text: "Release Notes"
href: articles/release_notes.html
- text: "respR in Use"
- text: "respR Citations"
href: articles/citations.html
- text: "Future Features"
href: articles/future.html
Expand Down
1 change: 1 addition & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No code changes, so should be no issues. Literally the only change is slight alteration to a value in one unit test. This is done in response to a package author contacting me because a pending update was rejected by CRAN due to this test failing in my package, which is a reverse dependency.
2 changes: 2 additions & 0 deletions man/inspect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/time_roll.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/validate_auto_rate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion pkgdown/pkgdown_script.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ pkgdown::build_site(lazy = TRUE, devel = TRUE, preview = TRUE)
# ? not sure what this does
#pkgdown::preview_site(pkg = ".", path = ".", preview = NA)

# builds top page
pkgdown::build_home(preview = TRUE)

# build a single article
pkgdown::build_article("closed")

pkgdown::build_article("flowthrough")
pkgdown::preview_page('articles/flowthrough.html')

# add a new vignetter
usethis::use_vignette("intermittent_old", "Intermittent-flow respirometry: Alternative approaches")


# sets up GH Actions workflow. Which isn't working.
# sets up GH Actions workflow. Needs tested.
#usethis::use_pkgdown_github_pages()


Expand All @@ -35,4 +38,7 @@ usethis::use_vignette("intermittent_old", "Intermittent-flow respirometry: Alter
## Sometimes gets stuck on git command.
## Stopping and building site then trying again seems to work.
## Although last time took MANY attempts
##
## BUT - even if it seems to freeze - check GHub and site - it might have successfully
## triggered the 'pages build and deployment' GH action anyway...
pkgdown::deploy_to_branch()
4 changes: 2 additions & 2 deletions tests/testthat/test-oxy_crit.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ capture.output({ ## stops printing of outputs on assigning
2.6003)
expect_equal(round(oxy_crit(squid, plot=F)$crit$crit.midpoint, 4),
2.5944)
expect_equal(round(oxy_crit(squid, method = "segmented", plot=F)$crit, 4),
2.6003)
expect_equal(round(oxy_crit(squid, method = "segmented", plot=F)$crit, 2),
2.60)
})

test_that("oxy_crit - works with oxygen~rate data", {
Expand Down
Loading

0 comments on commit 9fbe6ca

Please sign in to comment.