Skip to content

Commit ab5aaa1

Browse files
authored
Merge pull request #7 from nih-cfde/6-enable-automatic-pkgdown-builds
Enable automatic pkgdown builds
2 parents 24fe235 + d79cd7d commit ab5aaa1

File tree

6 files changed

+75
-22
lines changed

6 files changed

+75
-22
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
^pkgdown$
77
^.lintr$
88
.vscode$
9+
^\.github$
910
terraform/
1011
DEVELOPER.md
1112
^README\.Rmd$
1213
^CODE_OF_CONDUCT\.md$
14+

.github/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html

.github/workflows/pkgdown.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
11+
name: pkgdown.yaml
12+
13+
permissions: read-all
14+
15+
jobs:
16+
pkgdown:
17+
runs-on: ubuntu-latest
18+
# Only restrict concurrency for non-PR jobs
19+
concurrency:
20+
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
21+
env:
22+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
23+
GARGLE_ENCRYPTION_KEY: ${{ secrets.GARGLE_ENCRYPTION_KEY }}
24+
permissions:
25+
contents: write
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- uses: r-lib/actions/setup-pandoc@v2
30+
31+
- uses: r-lib/actions/setup-r@v2
32+
with:
33+
use-public-rspm: true
34+
35+
- uses: r-lib/actions/setup-r-dependencies@v2
36+
with:
37+
extra-packages: any::pkgdown, local::.
38+
needs: website
39+
40+
- name: Build site
41+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = TRUE)
42+
shell: Rscript {0}
43+
44+
- name: Deploy to GitHub pages 🚀
45+
if: github.event_name != 'pull_request'
46+
uses: JamesIves/[email protected]
47+
with:
48+
clean: false
49+
branch: gh-pages
50+
folder: docs

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ Suggests:
4040
testthat (>= 3.0.0),
4141
zoo
4242
VignetteBuilder: quarto
43+
URL: https://nih-cfde.github.io/programets/
44+
BugReports: https://github.com/nih-cfde/programets/issues
4345
Config/testthat/edition: 3

_pkgdown.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
url: ~
1+
url: https://seandavi.github.io/programets/
22
template:
33
bootstrap: 5
44
bslib:
55
bootswatch: materia
66
pkgdown-nav-height: 100px
7+

vignettes/googleanalytics.qmd

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ The package provides functions to authenticate with your Google account, retriev
2121

2222
# Getting started with `googleAnalyticsR`
2323

24-
2524
```{r}
26-
## setup
25+
#| label: setup
2726
library(googleAnalyticsR)
2827
library(programets)
2928
```
3029

31-
```{r eval=FALSE}
32-
## authenticate
30+
```{r}
31+
#| eval: false
32+
#| label: authenticate
3333
ga_auth(email = "[email protected]")
3434
```
3535

36-
```{r echo=FALSE}
36+
```{r}
37+
#| echo: false
38+
#| label: service_account
3739
json_file <- gargle::secret_decrypt_json(
3840
path = system.file(
3941
"secret",
@@ -49,25 +51,21 @@ ga_auth(email = "[email protected]")
4951
```
5052

5153
```{r}
52-
## get your accounts
54+
#| label: get-accounts
5355
account_list <- ga_account_list("ga4")
5456
55-
## account_list will have a column called "viewId"
56-
account_list$viewId
57+
## account_list will have a column called "propertyId"
58+
account_list$propertyId
5759
5860
## View account_list and pick the one that you want to use
5961
## In this case, we will use Bioconductor
6062
ga_id <- 388188354
61-
6263
```
6364

6465
The resulting `res` object will contain the data for the specified date range, metrics, and dimensions. You can view the first few rows of the data using the `head()` function.
6566

66-
67-
68-
6967
```{r}
70-
library(googleAnalyticsR)
68+
#| label: get-data
7169
library(lubridate)
7270
7371
start_date <- Sys.Date() - 365
@@ -85,28 +83,27 @@ daily_user_country_data <- ga_data(
8583

8684
```{r}
8785
#| label: moving-average
88-
8986
library(ggplot2)
9087
library(zoo)
9188
library(dplyr)
9289
9390
# Group by user type and country, then calculate rolling average
94-
moving_avg_data <- daily_user_country_data %>%
95-
arrange(date) %>%
96-
group_by(newVsReturning, country) %>%
91+
moving_avg_data <- daily_user_country_data |>
92+
arrange(date) |>
93+
group_by(newVsReturning, country) |>
9794
mutate(
9895
activeUsers_7day_avg = rollmean(activeUsers, k = 7, fill = NA, align = "right"),
9996
sessions_7day_avg = rollmean(sessions, k = 7, fill = NA, align = "right")
100-
) %>%
97+
) |>
10198
ungroup()
10299
103100
# Let's see the results
104101
head(moving_avg_data)
105102
106103
# Plot the moving average for active users
107-
moving_avg_data %>%
108-
group_by(date, newVsReturning) %>%
109-
summarise(activeUsers_7day_avg = sum(activeUsers_7day_avg, na.rm = TRUE)) %>%
104+
moving_avg_data |>
105+
group_by(date, newVsReturning) |>
106+
summarise(activeUsers_7day_avg = sum(activeUsers_7day_avg, na.rm = TRUE)) |>
110107
ggplot(aes(x = date, y = activeUsers_7day_avg, color = newVsReturning)) +
111108
geom_line() +
112109
labs(

0 commit comments

Comments
 (0)