Skip to content

Commit ecc69da

Browse files
committed
New site build
1 parent 8d806ef commit ecc69da

File tree

8 files changed

+139
-7
lines changed

8 files changed

+139
-7
lines changed

.github/workflows/pkgdown.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ jobs:
4242
extra-packages: any::pkgdown, local::.
4343
needs: website
4444

45+
- name: Install packages for badge generation
46+
run: install.packages(c("badger", "rmarkdown"))
47+
shell: Rscript {0}
48+
49+
- name: Render README
50+
run: rmarkdown::render("README.Rmd")
51+
shell: Rscript {0}
52+
53+
- name: Render index
54+
run: rmarkdown::render("index.Rmd")
55+
shell: Rscript {0}
56+
4557
- name: Build site
4658
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
4759
shell: Rscript {0}

BADGES.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Badge System Documentation
2+
3+
This document explains how the badge system works for the nowcaster package and how to maintain it.
4+
5+
## Overview
6+
7+
The nowcaster package uses badges to display:
8+
- Package version (automatically pulled from DESCRIPTION)
9+
- License information
10+
- Lifecycle stage (experimental)
11+
- R-CMD-check status from GitHub Actions
12+
13+
## Badge Generation
14+
15+
Badges are generated using the `badger` R package in two R Markdown files:
16+
- `README.Rmd` - generates badges for the GitHub repository README
17+
- `index.Rmd` - generates badges for the pkgdown website
18+
19+
### Badge Types
20+
21+
1. **Version Badge**: `badger::badge_devel(color = "blue")`
22+
- Automatically reads version from DESCRIPTION file
23+
- Links to the GitHub repository
24+
25+
2. **License Badge**: `badger::badge_license(url = "https://github.com/covid19br/nowcaster/blob/main/LICENSE.md")`
26+
- Shows license type from DESCRIPTION
27+
- Links to LICENSE.md file
28+
29+
3. **Lifecycle Badge**: `badger::badge_lifecycle(stage = "experimental")`
30+
- Shows development stage
31+
- Links to r-lib lifecycle documentation
32+
33+
4. **R-CMD-check Badge**: Static GitHub Actions badge
34+
- Shows status of automated R package checks
35+
- Updates automatically when checks run
36+
37+
## Build Process
38+
39+
### GitHub Actions (Automated)
40+
41+
The `.github/workflows/pkgdown.yaml` workflow:
42+
1. Installs necessary R packages (`badger`, `rmarkdown`)
43+
2. Renders `README.Rmd` to update badges with current package info
44+
3. Renders `index.Rmd` to update badges for the website
45+
4. Builds the pkgdown site with updated badges
46+
5. Deploys to GitHub Pages
47+
48+
### Local Testing
49+
50+
Run the `update_badges.sh` script to test badge generation locally:
51+
52+
```bash
53+
./update_badges.sh
54+
```
55+
56+
## Troubleshooting
57+
58+
### Badge not updating
59+
- Ensure DESCRIPTION file has correct GitHub URL in the URL field
60+
- Verify `badger` package is installed in build environment
61+
- Check that R Markdown files are being rendered before site build
62+
63+
### Version showing as hardcoded
64+
- Remove any `pkg = "package_name"` parameters from `badge_devel()` calls
65+
- Ensure GitHub repository URL is in DESCRIPTION URL field
66+
67+
### Missing badges on website
68+
- Verify `index.Rmd` contains all desired badge calls
69+
- Check that pkgdown workflow includes R Markdown rendering steps
70+
- Ensure `_pkgdown.yml` includes badges in strips configuration
71+
72+
## Maintenance
73+
74+
When updating package version:
75+
1. Update version in DESCRIPTION file
76+
2. Badges will automatically update on next website build
77+
3. No manual changes needed to badge code
78+
79+
When adding new badges:
80+
1. Add badge generation code to both `README.Rmd` and `index.Rmd`
81+
2. Test locally with `update_badges.sh`
82+
3. Commit changes - badges will update automatically on build

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ library(badger)
1414
<!-- badges: start -->
1515
<!-- `r badger::badge_cran_checks(pkg = NULL)` -->
1616
<!-- `r badger::badge_dependencies(pkg = NULL)` -->
17-
`r badger::badge_devel(pkg = "nowcaster", color = "blue")`
17+
`r badger::badge_devel(color = "blue")`
1818
`r badger::badge_license(url = "https://github.com/covid19br/nowcaster/blob/main/LICENSE.md")`
1919
`r badger::badge_lifecycle(stage = "experimental")`
2020
[![R-CMD-check](https://github.com/covid19br/nowcaster/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/covid19br/nowcaster/actions/workflows/R-CMD-check.yaml)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<!-- [![Dependencies](https://tinyverse.netlify.com/badge/nowcaster)](https://cran.r-project.org/package=nowcaster) -->
99

10-
[![](https://img.shields.io/badge/devel%20version-0.2.3-blue.svg)](https://github.com/nowcaster)
10+
[![](https://img.shields.io/badge/devel%20version-0.2.3-blue.svg)](https://github.com/covid19br/nowcaster)
1111
[![License: GPL (\>=
1212
3)](https://img.shields.io/badge/license-GPL%20(%3E=%203)-blue.svg)](https://github.com/covid19br/nowcaster/blob/main/LICENSE.md)
1313
[![](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)

_pkgdown.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ home:
3434
- citation
3535
- authors
3636
- dev
37+
strips:
38+
- badges
3739

index.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ library(badger)
1818
<!-- badges: start -->
1919
<!-- `r badger::badge_cran_checks(pkg = NULL)` -->
2020
<!-- `r badger::badge_dependencies(pkg = NULL)` -->
21-
`r badger::badge_devel(pkg = "nowcaster", color = "blue")`
21+
`r badger::badge_devel(color = "blue")`
2222
`r badger::badge_license(url = "https://github.com/covid19br/nowcaster/blob/main/LICENSE.md")`
2323
`r badger::badge_lifecycle(stage = "experimental")`
24+
[![R-CMD-check](https://github.com/covid19br/nowcaster/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/covid19br/nowcaster/actions/workflows/R-CMD-check.yaml)
2425
<!-- badges: end -->
2526

2627
`nowcaster` is an R package for “nowcasting” epidemiological time-series on individual level data.

update_badges.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Script to update badges in README and index files
4+
# This script regenerates the R markdown files to update badges with current package information
5+
6+
echo "Installing required R packages..."
7+
R --vanilla -e "
8+
if (!require('badger', quietly = TRUE)) install.packages('badger')
9+
if (!require('rmarkdown', quietly = TRUE)) install.packages('rmarkdown')
10+
"
11+
12+
echo "Generating badges to verify they work..."
13+
R --vanilla -e "
14+
library(badger)
15+
cat('Current version badge:', badge_devel(color = 'blue'), '\n')
16+
cat('License badge:', badge_license(url = 'https://github.com/covid19br/nowcaster/blob/main/LICENSE.md'), '\n')
17+
cat('Lifecycle badge:', badge_lifecycle(stage = 'experimental'), '\n')
18+
"
19+
20+
echo "Rendering R markdown files..."
21+
R --vanilla -e "
22+
if (requireNamespace('rmarkdown', quietly = TRUE)) {
23+
rmarkdown::render('README.Rmd')
24+
rmarkdown::render('index.Rmd')
25+
cat('Successfully rendered README.Rmd and index.Rmd\n')
26+
} else {
27+
cat('rmarkdown not available - this will be handled by GitHub Actions\n')
28+
}
29+
"
30+
31+
echo "Badge update process completed!"

vignettes/articles/1_structured_data.Rmd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ This is the whole premise of nowcasting, we model the case counts at time $t$ gi
4242
Hence, the model is given by the following:
4343

4444
$$\begin{equation}
45-
Y_{t,d} \sim NegBinom(\lambda_{t,d}, \phi), \\
46-
\log(\lambda_{t,d}) = \alpha + \beta_t + \gamma_d, \\
45+
Y_{t,d} \sim NegBinom(\lambda_{t,d}, \phi) \\
46+
\log(\lambda_{t,d}) = \alpha + \beta_t + \gamma_d \\
4747
\beta_t := u_t - u_{(t-1)} - u_{(t-2)} \sim N(0,\tau_{\beta}); \gamma_d := u_d - u_{(d-1)} \sim N(0, \tau_{\gamma})\\
48-
t=1,2,\ldots,T, \\ d=1,2,\ldots,D,
48+
t=1,2,\ldots,T \\
49+
d=1,2,\ldots,D \\
4950
\end{equation}$$
5051

5152
Where the intercept $\alpha$ follows a Gaussian distribution with a very large variance, $\beta_t$ follows a second order random walk with precision $\tau_\beta$, while $\gamma_d$ a first-order random walk with precision $\tau_\gamma$. The model is then completed by INLA default prior distributions for $\phi$, $\tau_\beta$, and $\tau_\gamma$. See [`nbinomial`](https://inla.r-inla-download.org/r-inla.org/doc/likelihood/likelihood-example.pdf), [`rw1`](https://inla.r-inla-download.org/r-inla.org/doc/latent/rw1.pdf) and [`rw2`](https://inla.r-inla-download.org/r-inla.org/doc/latent/rw1.pdf) INLA help pages.
@@ -124,7 +125,10 @@ The first improvement we have done on the baseline model for nowcasting with a n
124125
$$\begin{equation}Y_{t,d,a} \sim NegBinom(\lambda_{t,d,a}, \phi), \\
125126
\log(\lambda_{t,d,a}) = \alpha_a + \beta_{t,a} + \gamma_{d,a}, \\
126127
\beta_{t,a} := u_t - u_{(t-1)} - u_{(t-2)} \sim N(0,\tau_{a, \beta}); \gamma_{d,a} := u_d - u_{(d-1)} \sim N(0, \tau_{a, \gamma}) \\
127-
t=1,2,\ldots,T, \\ d=1,2,\ldots,D, \\ a=1,2,\ldots,A, \end{equation}$$
128+
t=1,2,\ldots,T, \\
129+
d=1,2,\ldots,D, \\
130+
a=1,2,\ldots,A, \\
131+
\end{equation}$$
128132

129133
where each age class, $a$, has an intercept $\alpha_a$ following a Gaussian distribution with a very large variance, the time-age random effects, $\beta_{t,a}$, follow a joint multivariate Gaussian distribution with a separable variance components an independent Gaussian term for the age classes with precision $\tau_{a,\beta}$ and a second order random walk term for the time with precision $\tau_{\beta}$. Analogously, the delay-age random effects, $\gamma_{d,a}$, follow a joint multivariate Gaussian distribution with a separable variance components an independent Gaussian term for the age classes with precision $\tau_{a,\gamma}$ and a first order random walk term for the time with precision $\tau_{\gamma}$. The model is then completed by INLA default prior distributions for $\phi$, $\tau_{a,\beta}$, $\tau_{a,\gamma}$, $\tau_{a,\beta}$ and $\tau_\gamma$. See [`nbinomial`](https://inla.r-inla-download.org/r-inla.org/doc/likelihood/likelihood-example.pdf), [`rw1`](https://inla.r-inla-download.org/r-inla.org/doc/latent/rw1.pdf) and [`rw2`](https://inla.r-inla-download.org/r-inla.org/doc/latent/rw1.pdf) INLA help pages.
130134

0 commit comments

Comments
 (0)