diff --git a/.Rbuildignore b/.Rbuildignore index 325065f..5ccf0e8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^cran-comments.md$ ^\.travis\.yml$ ^CRAN-RELEASE$ +^\.github$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..562fe0f --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,51 @@ +# 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: + +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")' diff --git a/.github/workflows/render-vignette-yaml.yml b/.github/workflows/render-vignette-yaml.yml new file mode 100644 index 0000000..f8ed103 --- /dev/null +++ b/.github/workflows/render-vignette-yaml.yml @@ -0,0 +1,25 @@ +on: + push: + branches: + - main +name: vignettes +jobs: + vignette: + name: Render-Vignette + runs-on: ubuntu-latest + container: + image: rocker/tidyverse + steps: + - uses: actions/checkout@v4 + - name: Install R dependencies + run: Rscript -e 'install.packages(c("DEoptimR","mathjaxr"))' + - name: Render Vignette + run: Rscript -e 'rmarkdown::render("vignette/guide.Rmd", output_dir = "vignette_output")' + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: vignette_output + CLEAN: true + diff --git a/R/functions.R b/R/functions.R index 94627ba..456fa42 100644 --- a/R/functions.R +++ b/R/functions.R @@ -5,6 +5,7 @@ #-------------------------------------------------------------------------------------------- # global variables # if(getRversion() >= "2.15.1") utils::globalVariables(c()) +utils::globalVariables("intcal20") #-------------------------------------------------------------------------------------------- getTruncatedModelChoices <- function(){ # Required in several functions, so avoids duplication if others are added to the package diff --git a/README.md b/README.md index 8a16d92..227e569 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ Max Planck Institute for the Science of Human History Pan African Evolution ResearchGroup -[![Build Status](https://app.travis-ci.com/AdrianTimpson/ADMUR.svg?branch=master)](https://app.travis-ci.com/AdrianTimpson/ADMUR) - # ADMUR ## Ancient Demographic Modelling Using Radiocarbon +[![R-CMD-check](https://github.com/simoncarrignon/ADMUR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/simoncarrignon/ADMUR/actions/workflows/R-CMD-check.yaml) + Statistical tools to directly model underlying population dynamics using date datasets (radiocarbon and other). ### Population modelling @@ -74,4 +74,4 @@ Also thanks to the following who have reported bugs, requested additional functi - Ricardo Fernandes - Mark G. Thomas - Robert Staniuk ---- \ No newline at end of file +--- diff --git a/man/SPDsimulationTest.Rd b/man/SPDsimulationTest.Rd index 1e9e25b..eb6e42f 100644 --- a/man/SPDsimulationTest.Rd +++ b/man/SPDsimulationTest.Rd @@ -68,7 +68,7 @@ The default N = 20000 can be increased if greater precision is required, however this can be very time costly. } \examples{ -\donttest{ +\dontrun{ # trivial example showing a single date can never be rejected under a uniform model: data <- data.frame(age=6500, sd=50, phase=1, datingType='14C') x <- SPDsimulationTest(data, diff --git a/man/getPhaseModelChoices.Rd b/man/getPhaseModelChoices.Rd index 8f91195..16901ef 100644 --- a/man/getPhaseModelChoices.Rd +++ b/man/getPhaseModelChoices.Rd @@ -4,7 +4,7 @@ \description{ Lists currently available models for the PDF of an archaeological phase, the number of parameters, and a brief description \loadmathjax } -\usage{getTruncatedModelChoices()} +\usage{getPhaseModelChoices()} \details{ diff --git a/man/intcal20.Rd b/man/intcal20.Rd index d323640..e785386 100644 --- a/man/intcal20.Rd +++ b/man/intcal20.Rd @@ -1,5 +1,5 @@ -\name{intcal20} \docType{data} +\name{intcal20} \alias{intcal20} \title{Northern hemisphere 2020 calibration curve} \description{ @@ -17,3 +17,4 @@ } \references{Reimer P, Austin WEN, Bard E, Bayliss A, Blackwell PG, Bronk Ramsey C, Butzin M, Cheng H, Edwards RL, Friedrich M, Grootes PM, Guilderson TP, Hajdas I, Heaton TJ, Hogg AG, Hughen KA, Kromer B, Manning SW, Muscheler R, Palmer JG, Pearson C, van der Plicht J, Reimer RW, Richards DA, Scott EM, Southon JR, Turney CSM, Wacker L, Adolphi F, Büntgen U, Capano M, Fahrni S, Fogtmann-Schulz A, Friedrich R, Köhler P, Kudsk S, Miyake F, Olsen J, Reinig F, Sakamoto M, Sookdeo A, Talamo S. 2020. The IntCal20 Northern Hemisphere radiocarbon age calibration curve (0-55 cal kBP). Radiocarbon 62. doi: 10.1017/RDC.2020.41.} +\keyword{datasets} diff --git a/man/mcmc.Rd b/man/mcmc.Rd index e8ba9af..fdddd1b 100644 --- a/man/mcmc.Rd +++ b/man/mcmc.Rd @@ -57,7 +57,7 @@ cal <- simulateCalendarDates(toy, N) age <- uncalibrateCalendarDates(cal, shcal20) data <- data.frame(age = age, sd = 50, phase = 1:N, datingType = '14C') -\donttest{ +\dontrun{ # Calibrate each phase, taking care to restrict to the modelled date range CalArray <- makeCalArray(shcal20, calrange = range(toy$year), inc = 5) PD <- phaseCalibrator(data, CalArray, remove.external = TRUE) diff --git a/man/phaseModel.Rd b/man/phaseModel.Rd index 9539849..dc64c31 100644 --- a/man/phaseModel.Rd +++ b/man/phaseModel.Rd @@ -38,9 +38,18 @@ # specify the prior probabilities of the parameter values of a gaussian model in a matrix mu.range <- c(5500,7000) sigma.range <- c(5,700) - prior.matrix <- matrix(1,150,150); prior.matrix <- prior.matrix/sum(prior.matrix) - row.names(prior.matrix) <- seq(min(mu.range),max(mu.range),length.out=nrow(prior.matrix)) - colnames(prior.matrix) <- seq(min(sigma.range),max(sigma.range),length.out=ncol(prior.matrix)) + prior.matrix <- matrix(1,150,150) + prior.matrix <- prior.matrix/sum(prior.matrix) + row.names(prior.matrix) <- seq( + from = min(mu.range), + to = max(mu.range), + length.out = nrow(prior.matrix) + ) + colnames(prior.matrix) <- seq( + from = min(sigma.range), + to = max(sigma.range), + length.out=ncol(prior.matrix) + ) # generate the posterior parameter probabilities pm <- phaseModel(data, calcurve, prior.matrix, model='norm', plot=TRUE) diff --git a/man/plotCalArray.Rd b/man/plotCalArray.Rd index 223c87b..d94dc38 100644 --- a/man/plotCalArray.Rd +++ b/man/plotCalArray.Rd @@ -16,6 +16,7 @@ \examples{ \donttest{ # generate a CalArray of the intcal20 curve covering 5500 calBP to 6000 calBP + data(intcal20) x <- makeCalArray( calcurve = intcal20, calrange = c(5500,6000), inc = 1 ) plotCalArray(x) } diff --git a/man/plotSimulationSummary.Rd b/man/plotSimulationSummary.Rd index 6e8046d..32800b3 100644 --- a/man/plotSimulationSummary.Rd +++ b/man/plotSimulationSummary.Rd @@ -21,7 +21,7 @@ Default NULL for legend.x and legend.y will automatically add a legend, which may not be ideally placed to avoid overlapping other components of the plot. To remove the legend, simply place well outside the boundary. } \examples{ - \donttest{ + \dontrun{ summary <- SPDsimulationTest(data=SAAD, calcurve=shcal20, calrange=c(2500,14000), diff --git a/vignettes/guide.Rmd b/vignettes/guide.Rmd index 92d832b..c0c4851 100644 --- a/vignettes/guide.Rmd +++ b/vignettes/guide.Rmd @@ -11,13 +11,18 @@ output: logo: logo.jpg vignette: > %\VignetteEngine{knitr::rmarkdown} - %\VignetteIndexEntry{Guide to using ADMUR} + %\VignetteIndexEntry{ADMUR: Ancient Demographic Modelling Using Radiocarbon } %\usepackage[utf8]{inputenc} --- + +```{r setup, include=FALSE} +options(rmarkdown.html_vignette.check_title = FALSE) +``` + ********** # 1. Overview @@ -93,7 +98,7 @@ data6[1:10,] ********** -# 2. radiocarbon date calibration and SPDs +# 2. Radiocarbon date calibration and SPDs Generating a single calibrated date distribution, or a Summed Probability Distribution (SPD) of several calibrated dates, requires either a two-step process to give the user full control of the date range and temporal resolution, or a simpler one step process using a wrapper function that automatically estimates a sensible date range and resolution from the dataset. @@ -124,6 +129,7 @@ Generating the SPD without the wrapper gives you more control, and requires a tw This is useful for improving computational times if generating many SPDs, for example in a simulation framework, since the CalArray needs generating only once. ```{r, eval = TRUE, fig.height = 3, fig.width=7, fig.align = "center", dev='jpeg', quality=100, warning=FALSE} +data(intcal20) data <- data.frame( age = c(9144), sd=c(151) ) CalArray <- makeCalArray( calcurve=intcal20, calrange=c(8000,13000) ) cal <- summedCalibrator(data, CalArray) @@ -563,7 +569,7 @@ plotPD(spd) lines(mod.combo, col=cols[1], lwd=5) legend(x=4000, y=max(spd)*1.2, lwd=5, col=cols[1], bty='n', legend=c('combo.sine.logistic')) ``` -![Example of a combination model](combination_model.png){width=680px} +![Example of a combination model](combo_models.png){width=680px} **********