Skip to content

Commit 2980009

Browse files
Copilotgvegayonaoliveram
authored
Add degree and time of adoption diagnostic function (#57)
* Initial plan * Implement degree_adoption_diagnostic function with comprehensive tests Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com> * Fix print method formatting and complete implementation Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com> * Review changes: - Expanded degree_adoption_diagnostic to accept generic graphs + TOA - Improved print method with CI-aware interpretation - Updated tests for new input validation * multi-diffusion support (behavior/combine), undirected network support, safer bootstrap & printer; tests + docs added * Refactor degree_adoption_diagnostic: Move to separate file, update documentation syntax, add NEWS entry Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com> * Updating docs * Adding new workflow and working on R CMD check * Fixing actions * Updating readme * Fix formatting of valgrind variable in workflow name * Addressing errors and warnings * Updating printer: combo mode + bootstrap NA fix * Updating README and version number * Remove build-targz.yml and update NEWS.md for v1.24.0 Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com> * Renaming codechunks to avoid errors * Trying to fix LR ending * Avoiding building manual in valgrind and building to upload --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com> Co-authored-by: aoliveram <anibal.olivera.m@gmail.com> Co-authored-by: George G. Vega Yon <g.vegayon@gmail.com>
1 parent aeea532 commit 2980009

57 files changed

Lines changed: 1584 additions & 267 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
FROM rocker/tidyverse:4.4.0
1+
FROM ghcr.io/rocker-org/devcontainer/tidyverse:4.5
22

33
# RUN \
44
# echo 'options(repos=c(CRAN="https://packagemanager.posit.co/cran/__linux__/bookworm/latest"))' >> ~/.Rprofile && \
55
# Rscript --vanilla -e 'getOption("repos")'
66

7-
# Adding R packages
8-
RUN install2.r Rcpp sna network networkDynamic Matrix MASS MatchIt SparseM igraph \
9-
viridisLite covr testthat knitr rmarkdown ape RSiena survival RcppArmadillo
10-
11-
RUN install2.r languageserver httpgd
7+
RUN install2.r --error languageserver && installGithub.r nx10/httpgd
128

139
RUN apt-get update && apt-get install --no-install-recommends -y valgrind gdb \
1410
libglpk-dev
1511

12+
# Adding R packages
13+
RUN install2.r --error Rcpp sna network networkDynamic Matrix MASS MatchIt SparseM igraph \
14+
viridisLite covr testthat knitr rmarkdown ape RSiena survival RcppArmadillo
15+
1616
CMD ["bash"]

.devcontainer/devcontainer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
33
{
4-
"name": "epiworldR",
4+
"name": "netdiffuseR",
55
"build": {
6-
"dockerfile": "Dockerfile"
6+
"dockerfile": "Containerfile"
77
},
88
"customizations": {
99
"vscode": {
1010
"extensions": [
1111
"reditorsupport.r",
1212
"rdebugger.r-debugger",
1313
"quarto.quarto",
14-
"tianyishi.rmarkdown"
14+
"tianyishi.rmarkdown",
15+
"github.vscode-github-actions"
1516
]
1617
}
1718
},
1819
"mounts": [
1920
// Mount the .vscode configuration into the container
2021
"source=${localWorkspaceFolder}/.devcontainer/.vscode,target=/workspaces/${localWorkspaceFolderBasename}/.vscode,type=bind,consistency=cached"
21-
]
22+
],
2223
// Features to add to the dev container. More info: https://containers.dev/features.
2324
// "features": {},
2425

@@ -32,5 +33,5 @@
3233
// "customizations": {},
3334

3435
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
35-
// "remoteUser": "root"
36+
"remoteUser": "root"
3637
}

.github/copilot-instructions.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copilot Instructions for netdiffuseR
2+
3+
## Documentation Style
4+
5+
When writing roxygen2 documentation, prefer markdown syntax over LaTeX:
6+
7+
- Use `` `code` `` instead of `\code{code}`
8+
- Use `` `[function()]` `` instead of `\code{\link{function}}`
9+
- Use markdown bullet lists instead of `\itemize{}`
10+
- Use markdown formatting for emphasis and structure
11+
12+
## Code Style
13+
14+
- Follow existing code patterns and conventions in the package
15+
- Use meaningful variable names and keep functions focused
16+
- Add comments only when they match the existing style or explain complex logic
17+
- Prefer using existing libraries over adding new dependencies
18+
19+
## Testing
20+
21+
- Add comprehensive tests for new functions
22+
- Include edge cases and error conditions
23+
- Test with the existing sample datasets when possible
24+
- Validate input parameters and handle errors gracefully
25+
26+
## Examples
27+
28+
- Use `\dontrun{}` only when examples take a long time to run
29+
- Prefer examples that can execute quickly for CRAN checks
30+
- Use existing package datasets in examples when available

.github/workflows/pkgdown.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
id-token: write
2525
pages: write
2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v5
2828

2929
- uses: r-lib/actions/setup-pandoc@v2
3030
with:
@@ -35,6 +35,8 @@ jobs:
3535
- uses: r-lib/actions/setup-r-dependencies@v2
3636
with:
3737
extra-packages: any::pkgdown
38+
install-quarto: true
39+
install-pandoc: true
3840

3941
- name: Install the package
4042
run: R CMD INSTALL .
@@ -44,7 +46,7 @@ jobs:
4446
shell: Rscript {0}
4547

4648
- name: Upload artifact for GH pages deployment
47-
uses: actions/upload-pages-artifact@v3
49+
uses: actions/upload-pages-artifact@v5
4850
with:
4951
path: "docs/"
5052

.github/workflows/r.yml

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ jobs:
1515
R-CMD-check:
1616
runs-on: ${{ matrix.config.os }}
1717

18-
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
18+
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) (valgrind:${{ matrix.config.valgrind }})
1919

2020
strategy:
2121
fail-fast: false
2222
matrix:
2323
config:
2424
- {os: macOS-latest, r: 'release'}
25+
- {os: macOS-latest, r: 'devel', http-user-agent: 'release'}
2526
- {os: windows-latest, r: 'release'}
27+
# - {os: windows-latest, r: 'devel', http-user-agent: 'release'}
2628
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
2729
- {os: ubuntu-latest, r: 'release'}
2830
- {os: ubuntu-latest, r: 'devel', valgrind: true, http-user-agent: 'release'}
@@ -32,9 +34,12 @@ jobs:
3234
R_KEEP_PKG_SOURCE: yes
3335

3436
steps:
35-
- uses: actions/checkout@v4
37+
# Fix suggested by
38+
# https://msmith.de/2020/03/12/r-cmd-check-github-actions.html
39+
- name: Configure git
40+
run: git config --global core.autocrlf false
3641

37-
- uses: r-lib/actions/setup-pandoc@v2
42+
- uses: actions/checkout@v5
3843

3944
- uses: r-lib/actions/setup-r@v2
4045
with:
@@ -46,6 +51,8 @@ jobs:
4651
with:
4752
extra-packages: any::rcmdcheck
4853
needs: check
54+
install-quarto: true
55+
install-pandoc: true
4956

5057
- uses: r-lib/actions/check-r-package@v2
5158
if: ${{ matrix.config.valgrind != true }}
@@ -56,36 +63,43 @@ jobs:
5663
check-dir: '"check"'
5764
error-on: '"error"'
5865

59-
- name: Setup valgrind
60-
if: ${{ matrix.config.valgrind == true }}
66+
- name: Install valgrind
67+
if: ${{ matrix.config.valgrind }}
6168
run: |
6269
sudo apt-get update
63-
sudo apt-get install -y valgrind --no-install-recommends
64-
shell: bash
70+
sudo apt-get install -y --no-install-recommends valgrind
6571
66-
- name: Check with Valgrind
67-
if: ${{ matrix.config.valgrind == true }}
68-
env:
69-
_R_CHECK_CRAN_INCOMING_REMOTE_: false
70-
run: |
71-
options(crayon.enabled = TRUE)
72-
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--use-valgrind"), error_on = "error", check_dir = "check")
73-
shell: Rscript {0}
72+
- uses: r-lib/actions/check-r-package@v2
73+
if: ${{ matrix.config.valgrind }}
74+
with:
75+
args: 'c("--as-cran", "--use-valgrind", "--no-manual")'
76+
upload-results: true
77+
78+
build-pkg:
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v5
7482

75-
- name: Upload check results
76-
if: failure()
77-
uses: actions/upload-artifact@main
83+
- uses: r-lib/actions/setup-r@v2
7884
with:
79-
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
80-
path: check
85+
r-version: 'release'
86+
use-public-rspm: true
8187

82-
- name: Build the package
83-
if: ${{ matrix.config.os == 'ubuntu-latest' && (matrix.config.r == 'release' || matrix.config.r == 'devel') && (matrix.config.valgrind != true) }}
88+
- uses: r-lib/actions/setup-r-dependencies@v2
89+
with:
90+
extra-packages: any::devtools
91+
92+
- name: Build package
8493
run: R CMD build .
8594

86-
- uses: actions/upload-artifact@v4
87-
if: ${{ matrix.config.os == 'ubuntu-latest' && (matrix.config.r == 'release' || matrix.config.r == 'devel') && (matrix.config.valgrind != true) }}
95+
- name: Upload package artifact
96+
uses: actions/upload-artifact@v5
8897
with:
89-
name: netdiffuseR-built-package-${{ matrix.config.os }}-${{ matrix.config.r }}
90-
path: netdiffuseR_*.tar.gz
91-
retention-days: 7
98+
name: R-package
99+
path: '*.tar.gz'
100+
101+
102+
103+
104+
105+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ inst/doc
2222
*.tex
2323
playground/
2424
doc/
25+
26+
# Other files
27+
.vscode/
28+
config.status
29+
src/Makevars

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: netdiffuseR
22
Title: Analysis of Diffusion and Contagion Processes on Networks
3-
Version: 1.23.0
3+
Version: 1.24.0
44
Authors@R: c(
55
person("George", "Vega Yon", email="g.vegayon@gmail.com", role=c("aut", "cre"),
66
comment=c(ORCID = "0000-0002-3171-0844", what="Rewrite functions with Rcpp, plus new features")
@@ -51,7 +51,7 @@ Suggests:
5151
survival
5252
VignetteBuilder: knitr
5353
LinkingTo: Rcpp, RcppArmadillo
54-
RoxygenNote: 7.3.2
54+
RoxygenNote: 7.3.3
5555
Encoding: UTF-8
5656
URL: https://github.com/USCCANA/netdiffuseR,
5757
https://USCCANA.github.io/netdiffuseR/
@@ -66,6 +66,7 @@ Collate:
6666
'bootnet.r'
6767
'citer_environment.R'
6868
'data.r'
69+
'degree_adoption_diagnostic.R'
6970
'diffnet-c.R'
7071
'diffnet-class.r'
7172
'diffnet-indexing.r'

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ help:
99
@echo " make docs - Generate documentation"
1010

1111
install:
12-
R CMD INSTALL .
12+
Rscript --vanilla -e 'devtools::install()'
1313

1414
build:
1515
R CMD build .
1616

17-
README.md: README.Rmd
18-
Rscript -e 'rmarkdown::render("README.Rmd")'
17+
README.md: README.qmd
18+
quarto render README.qmd
1919

20-
check: netdiffuseR_$(VERSION).tar.gz
21-
R CMD check --as-cran netdiffuseR_$(VERSION).tar.gz
20+
check:
21+
Rscript --vanilla -e 'devtools::check()'
2222

2323
checkv: netdiffuseR_$(VERSION).tar.gz
2424
R CMD check --as-cran --use-valgrind netdiffuseR_$(VERSION).tar.gz

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ S3method(plot_diffnet2,diffnet)
6666
S3method(plot_threshold,array)
6767
S3method(plot_threshold,default)
6868
S3method(plot_threshold,diffnet)
69+
S3method(print,degree_adoption_diagnostic)
6970
S3method(print,diffnet)
7071
S3method(print,diffnet_bootnet)
7172
S3method(print,diffnet_diffmap)
@@ -99,6 +100,7 @@ export(classify_adopters)
99100
export(classify_graph)
100101
export(compare_matrix)
101102
export(cumulative_adopt_count)
103+
export(degree_adoption_diagnostic)
102104
export(dgr)
103105
export(diag_expand)
104106
export(diffmap)

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Changes in netdiffuseR version 1.24.0 (DEV)
2+
3+
* New function `degree_adoption_diagnostic()` analyzes the correlation between network
4+
centrality measures (in-degree and out-degree) and time of adoption to identify
5+
whether opinion leaders were supporters or opposers in diffusion processes.
6+
The function supports multi-diffusion objects, undirected networks, and includes
7+
bootstrap confidence intervals.
8+
19
# Changes in netdiffuseR version 1.23.0 (2025-06-10)
210

311
* New methods for simulating multi-diffusion models.

0 commit comments

Comments
 (0)