From 7d72ac6edc83cc339efef785bc56f175a64c19f0 Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 01:55:22 +0100 Subject: [PATCH 01/37] UPDATE --- .github/workflows/mac_r.yml | 41 +++++++++++-------------------------- .github/workflows/r.yml | 24 +++++++++++++--------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index b9c1e39..05d4096 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -5,7 +5,7 @@ # # See https://github.com/r-lib/actions/tree/master/examples#readme for # additional example workflows available for the R community. -name: R Package CI for Windows +name: R Package CI for MacOS on: push: @@ -18,28 +18,23 @@ permissions: jobs: build: - runs-on: windows-latest + runs-on: macos-latest strategy: matrix: - os: [windows-latest] + os: [macos-latest] r-version: ['4.1.1'] steps: - uses: actions/checkout@v4 - - name: Install system dependencies on Windows - run: | - choco install jags - choco install miktex - choco install rtools - choco install gfortran - shell: cmd + - name: Install JAGS on macOS + run: brew install jags - - name: Update MiKTeX package database - run: | - mpm --update-db - mpm --update - shell: cmd + - name: Install LaTeX on macOS + run: brew install --cask mactex-no-gui + + - name: Install gfortran + run: brew install gfortran - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 @@ -49,43 +44,31 @@ jobs: - name: Install remotes package run: | Rscript -e "install.packages('remotes')" - shell: Rscript {0} - name: Install package dependencies run: | Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" - shell: Rscript {0} - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} # 使用正确的 PAT run: | Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" - shell: Rscript {0} - name: Set CRAN mirror and install other R package dependencies env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} # 使用正确的 PAT run: | Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" - shell: Rscript {0} - name: Install rcmdcheck package run: | Rscript -e "install.packages('rcmdcheck')" - shell: Rscript {0} - name: Check run: | Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" - shell: Rscript {0} - name: Test (optional) run: | Rscript -e "devtools::test()" - shell: Rscript {0} - - env: - TZ: UTC - _R_CHECK_SYSTEM_CLOCK_: FALSE - NOT_CRAN: true diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index affe633..b9c1e39 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -27,18 +27,12 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up R ${{ matrix.r-version }} - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.r-version }} - - name: Install system dependencies on Windows run: | - choco install qpdf - choco install pkgconfiglite - choco install make - choco install miktex # Install LaTeX - choco install rtools # Install Rtools if needed + choco install jags + choco install miktex + choco install rtools + choco install gfortran shell: cmd - name: Update MiKTeX package database @@ -47,11 +41,21 @@ jobs: mpm --update shell: cmd + - name: Set up R ${{ matrix.r-version }} + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.r-version }} + - name: Install remotes package run: | Rscript -e "install.packages('remotes')" shell: Rscript {0} + - name: Install package dependencies + run: | + Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" + shell: Rscript {0} + - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} From 7d2be756684d48ba1eee4526030b1a2c6f4d75a9 Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 17:34:36 +0100 Subject: [PATCH 02/37] UPDATE --- .github/workflows/mac_r.yml | 17 +++++++++-------- .github/workflows/r.yml | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 05d4096..7a4db6a 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -36,31 +36,32 @@ jobs: - name: Install gfortran run: brew install gfortran + - name: Update TeX packages + run: sudo tlmgr update --self --all + - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.r-version }} + - name: Set CRAN mirror + run: | + Rscript -e "options(repos = c(CRAN = 'https://cran.rstudio.com/'))" + - name: Install remotes package run: | Rscript -e "install.packages('remotes')" - name: Install package dependencies run: | - Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" + Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'), dependencies=TRUE)" - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} # 使用正确的 PAT + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" - - name: Set CRAN mirror and install other R package dependencies - env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} # 使用正确的 PAT - run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" - - name: Install rcmdcheck package run: | Rscript -e "install.packages('rcmdcheck')" diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index b9c1e39..af7631d 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -32,7 +32,6 @@ jobs: choco install jags choco install miktex choco install rtools - choco install gfortran shell: cmd - name: Update MiKTeX package database From a1af5bf5b0ebacfb772da8e6b2e29f0ac5fadca6 Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 17:41:07 +0100 Subject: [PATCH 03/37] UPDATE --- .github/workflows/r.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index af7631d..3ebb283 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -88,3 +88,4 @@ jobs: TZ: UTC _R_CHECK_SYSTEM_CLOCK_: FALSE NOT_CRAN: true + From 14fdb5a07a5bef5022058020762bb27aa9ab9d8c Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 17:51:39 +0100 Subject: [PATCH 04/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 7a4db6a..d56580d 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -33,21 +33,15 @@ jobs: - name: Install LaTeX on macOS run: brew install --cask mactex-no-gui - - name: Install gfortran - run: brew install gfortran - - - name: Update TeX packages - run: sudo tlmgr update --self --all + - name: Add TeX Live to PATH + run: | + echo "/usr/local/texlive/2023basic/bin/x86_64-darwin/" >> $GITHUB_PATH - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.r-version }} - - name: Set CRAN mirror - run: | - Rscript -e "options(repos = c(CRAN = 'https://cran.rstudio.com/'))" - - name: Install remotes package run: | Rscript -e "install.packages('remotes')" @@ -62,6 +56,12 @@ jobs: run: | Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" + - name: Set CRAN mirror and install other R package dependencies + env: + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + run: | + Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" + - name: Install rcmdcheck package run: | Rscript -e "install.packages('rcmdcheck')" @@ -73,3 +73,4 @@ jobs: - name: Test (optional) run: | Rscript -e "devtools::test()" + From 0360659776ea6b8a4822761ec87d6017666e25ae Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 17:56:35 +0100 Subject: [PATCH 05/37] Update r.yml --- .github/workflows/r.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 3ebb283..edd2d49 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -34,12 +34,6 @@ jobs: choco install rtools shell: cmd - - name: Update MiKTeX package database - run: | - mpm --update-db - mpm --update - shell: cmd - - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: @@ -88,4 +82,3 @@ jobs: TZ: UTC _R_CHECK_SYSTEM_CLOCK_: FALSE NOT_CRAN: true - From a0c2d64a506a0badf9313c34340b5c1c6f4ef513 Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 18:04:32 +0100 Subject: [PATCH 06/37] UPDATE --- .github/workflows/r.yml | 29 +++++++++++++++-------------- _pkgdown.yml | 6 +++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index edd2d49..b214655 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -41,44 +41,45 @@ jobs: - name: Install remotes package run: | - Rscript -e "install.packages('remotes')" - shell: Rscript {0} + Rscript -e \"install.packages('remotes')\" + shell: cmd - name: Install package dependencies run: | - Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" - shell: Rscript {0} + Rscript -e \"install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))\" + shell: cmd - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | - Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" - shell: Rscript {0} + Rscript -e \"remotes::install_github('cran/basicspace', force = TRUE)\" + shell: cmd - name: Set CRAN mirror and install other R package dependencies env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" - shell: Rscript {0} + Rscript -e \"options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'))\" + shell: cmd - name: Install rcmdcheck package run: | - Rscript -e "install.packages('rcmdcheck')" - shell: Rscript {0} + Rscript -e \"install.packages('rcmdcheck')\" + shell: cmd - name: Check run: | - Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" - shell: Rscript {0} + Rscript -e \"rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')\" + shell: cmd - name: Test (optional) run: | - Rscript -e "devtools::test()" - shell: Rscript {0} + Rscript -e \"devtools::test() \" + shell: cmd env: TZ: UTC _R_CHECK_SYSTEM_CLOCK_: FALSE NOT_CRAN: true + diff --git a/_pkgdown.yml b/_pkgdown.yml index a297e0f..91256e7 100755 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -75,11 +75,11 @@ navbar: menu: - text: "Chapter 2: Analyzing Issue Scales" href: articles/ch2.html - - text: "Chapter 3: Similarities and Dissimilarities Data (Coming soon)" - href: + - text: "Chapter 3: Similarities and Dissimilarities Data" + href: articles/ch3.html - text: "Chapter 4: Rating Scale Data" href: articles/ch4.html - - text: "Chapter 5: Binary Choice Data (Coming soon)" + - text: "Chapter 5: Binary Choice Data (In prgoress)" href: articles/ch5.html - text: "Chapter 6: Bayesian Scaling Models (Coming soon)" href: From 43ff96e937bf16e0260a34e9cd4146c37d61f0eb Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 18:25:18 +0100 Subject: [PATCH 07/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index d56580d..4c334b1 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -14,7 +14,7 @@ on: branches: [ "master" ] permissions: - contents: read + contents: read jobs: build: @@ -30,18 +30,19 @@ jobs: - name: Install JAGS on macOS run: brew install jags - - name: Install LaTeX on macOS - run: brew install --cask mactex-no-gui - - - name: Add TeX Live to PATH - run: | - echo "/usr/local/texlive/2023basic/bin/x86_64-darwin/" >> $GITHUB_PATH + - name: Install gfortran for ARM (M1/M2) + run: brew install gcc - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.r-version }} + - name: Install TinyTeX + run: | + Rscript -e "install.packages('tinytex')" + Rscript -e "tinytex::install_tinytex()" + - name: Install remotes package run: | Rscript -e "install.packages('remotes')" @@ -73,4 +74,3 @@ jobs: - name: Test (optional) run: | Rscript -e "devtools::test()" - From 651f0b4c6e34d83ff9502ffdcf2cf731f8978919 Mon Sep 17 00:00:00 2001 From: David Liao Date: Sun, 18 Aug 2024 23:56:48 +0100 Subject: [PATCH 08/37] UPDATE --- .github/workflows/mac_r.yml | 37 ++++++++++++++++++++++++++++++------- .github/workflows/r.yml | 25 +++++++++++++++---------- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 4c334b1..cd2d221 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -30,9 +30,17 @@ jobs: - name: Install JAGS on macOS run: brew install jags - - name: Install gfortran for ARM (M1/M2) + - name: Install gcc (includes gfortran) run: brew install gcc + - name: Ensure gfortran is in PATH + run: | + echo "/opt/homebrew/bin" >> $GITHUB_PATH + echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH + + - name: Check gfortran installation + run: gfortran --version + - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: @@ -43,34 +51,49 @@ jobs: Rscript -e "install.packages('tinytex')" Rscript -e "tinytex::install_tinytex()" + - name: Set CRAN mirror + run: | + Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/'))" + shell: Rscript {0} + - name: Install remotes package run: | Rscript -e "install.packages('remotes')" - name: Install package dependencies run: | - Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'), dependencies=TRUE)" + Rscript -e "install.packages(c('smacof', 'vegan'), dependencies = TRUE)" + shell: Rscript {0} - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} run: | Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" + shell: Rscript {0} - - name: Set CRAN mirror and install other R package dependencies - env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + - name: Install other R package dependencies run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" + Rscript -e "install.packages(c('rjags', 'ggplot2', 'knitr'))" + shell: Rscript {0} - name: Install rcmdcheck package run: | Rscript -e "install.packages('rcmdcheck')" + shell: Rscript {0} - name: Check run: | Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" + shell: Rscript {0} - name: Test (optional) run: | Rscript -e "devtools::test()" + shell: Rscript {0} + + env: + R_LIBS_USER: /Users/runner/work/_temp/Library + TZ: UTC + _R_CHECK_SYSTEM_CLOCK_: FALSE + NOT_CRAN: true diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index b214655..6a00ca0 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -14,7 +14,7 @@ on: branches: [ "master" ] permissions: - contents: read + contents: read jobs: build: @@ -34,6 +34,10 @@ jobs: choco install rtools shell: cmd + - name: Verify JAGS installation + run: jags --version + shell: cmd + - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: @@ -41,45 +45,46 @@ jobs: - name: Install remotes package run: | - Rscript -e \"install.packages('remotes')\" + Rscript -e "install.packages('remotes')" shell: cmd - - name: Install package dependencies + - name: Install CRAN packages including rjags run: | - Rscript -e \"install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))\" + Rscript -e "options(repos = 'https://cloud.r-project.org/')" + Rscript -e "install.packages('rjags')" + Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'), dependencies=TRUE)" shell: cmd - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | - Rscript -e \"remotes::install_github('cran/basicspace', force = TRUE)\" + Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" shell: cmd - name: Set CRAN mirror and install other R package dependencies env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | - Rscript -e \"options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'))\" + Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('ggplot2', 'knitr'));" shell: cmd - name: Install rcmdcheck package run: | - Rscript -e \"install.packages('rcmdcheck')\" + Rscript -e "install.packages('rcmdcheck')" shell: cmd - name: Check run: | - Rscript -e \"rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')\" + Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" shell: cmd - name: Test (optional) run: | - Rscript -e \"devtools::test() \" + Rscript -e "devtools::test()" shell: cmd env: TZ: UTC _R_CHECK_SYSTEM_CLOCK_: FALSE NOT_CRAN: true - From 6f2e9851897dbdf29b9ab6f5d9481f94e4590b2b Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 00:37:05 +0100 Subject: [PATCH 09/37] Update r.yml --- .github/workflows/r.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 6a00ca0..ab42577 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -27,11 +27,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install system dependencies on Windows + - name: Install JAGS on Windows + run: choco install jags -y + shell: cmd + + - name: Add JAGS to PATH run: | - choco install jags - choco install miktex - choco install rtools + echo "C:\Program Files\JAGS\JAGS-4.3.0\bin" >> $GITHUB_PATH shell: cmd - name: Verify JAGS installation From bb83f9388df385306f92267ce9b5cd3980ae9a44 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 00:38:46 +0100 Subject: [PATCH 10/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index cd2d221..01d00ca 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -52,45 +52,31 @@ jobs: Rscript -e "tinytex::install_tinytex()" - name: Set CRAN mirror - run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/'))" - shell: Rscript {0} + run: Rscript -e 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' + shell: /bin/bash -e {0} - name: Install remotes package - run: | - Rscript -e "install.packages('remotes')" + run: Rscript -e 'install.packages("remotes")' - name: Install package dependencies - run: | - Rscript -e "install.packages(c('smacof', 'vegan'), dependencies = TRUE)" - shell: Rscript {0} + run: Rscript -e 'install.packages(c("smacof", "vegan"), dependencies = TRUE)' - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.GITHUB_PAT }} - run: | - Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" - shell: Rscript {0} + run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' - name: Install other R package dependencies - run: | - Rscript -e "install.packages(c('rjags', 'ggplot2', 'knitr'))" - shell: Rscript {0} + run: Rscript -e 'install.packages(c("rjags", "ggplot2", "knitr"))' - name: Install rcmdcheck package - run: | - Rscript -e "install.packages('rcmdcheck')" - shell: Rscript {0} + run: Rscript -e 'install.packages("rcmdcheck")' - name: Check - run: | - Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" - shell: Rscript {0} + run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' - name: Test (optional) - run: | - Rscript -e "devtools::test()" - shell: Rscript {0} + run: Rscript -e 'devtools::test()' env: R_LIBS_USER: /Users/runner/work/_temp/Library From f6ad4a15314c2bdd7ee7d344554a02cf4eb7ba9e Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 00:49:07 +0100 Subject: [PATCH 11/37] Update r.yml --- .github/workflows/r.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index ab42577..6b153ef 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -27,9 +27,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install JAGS on Windows - run: choco install jags -y - shell: cmd + - name: Download and install JAGS + run: | + Invoke-WebRequest -Uri "https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download" -OutFile "JAGS-4.3.0.exe" + Start-Process -FilePath .\JAGS-4.3.0.exe -ArgumentList '/S' -NoNewWindow -Wait + shell: powershell - name: Add JAGS to PATH run: | @@ -59,14 +61,14 @@ jobs: - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} run: | Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" shell: cmd - name: Set CRAN mirror and install other R package dependencies env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} run: | Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('ggplot2', 'knitr'));" shell: cmd From 7a606e3de7599d25ef5185cca9743ff579caa025 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 00:53:11 +0100 Subject: [PATCH 12/37] Update r.yml --- .github/workflows/r.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 6b153ef..1348b5c 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -29,7 +29,7 @@ jobs: - name: Download and install JAGS run: | - Invoke-WebRequest -Uri "https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download" -OutFile "JAGS-4.3.0.exe" + curl -L -o JAGS-4.3.0.exe https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download Start-Process -FilePath .\JAGS-4.3.0.exe -ArgumentList '/S' -NoNewWindow -Wait shell: powershell From be4e4fa3255747a77ae5a6f339f3d3a8062305d7 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 01:19:01 +0100 Subject: [PATCH 13/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 01d00ca..e0f3f00 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -59,13 +59,14 @@ jobs: run: Rscript -e 'install.packages("remotes")' - name: Install package dependencies - run: Rscript -e 'install.packages(c("smacof", "vegan"), dependencies = TRUE)' + run: Rscript -e 'install.packages(c("smacof", "basicspace", "vegan"), dependencies = TRUE)' - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' + - name: Install other R package dependencies run: Rscript -e 'install.packages(c("rjags", "ggplot2", "knitr"))' From 6d384dee45ae6dde4fc4a298ac7b988907769fbb Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 01:19:48 +0100 Subject: [PATCH 14/37] Update r.yml --- .github/workflows/r.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 1348b5c..0e7db3f 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -61,14 +61,14 @@ jobs: - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" shell: cmd - name: Set CRAN mirror and install other R package dependencies env: - GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: | Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('ggplot2', 'knitr'));" shell: cmd From f128e520cd964cfce7e021025947786a23b8f381 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 01:30:39 +0100 Subject: [PATCH 15/37] Update r.yml --- .github/workflows/r.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 0e7db3f..d5822ca 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -29,8 +29,8 @@ jobs: - name: Download and install JAGS run: | - curl -L -o JAGS-4.3.0.exe https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download - Start-Process -FilePath .\JAGS-4.3.0.exe -ArgumentList '/S' -NoNewWindow -Wait + Invoke-WebRequest -Uri "https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download" -OutFile "JAGS-4.3.0.exe" + Start-Process -FilePath ".\JAGS-4.3.0.exe" -ArgumentList '/S' -NoNewWindow -Wait shell: powershell - name: Add JAGS to PATH From a4a5e3ac00bb012578af0a83c0e6db7ed949aa4f Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 01:33:41 +0100 Subject: [PATCH 16/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index e0f3f00..c40240d 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -5,7 +5,7 @@ # # See https://github.com/r-lib/actions/tree/master/examples#readme for # additional example workflows available for the R community. -name: R Package CI for MacOS +name: R Package CI for macOS on: push: @@ -33,13 +33,14 @@ jobs: - name: Install gcc (includes gfortran) run: brew install gcc - - name: Ensure gfortran is in PATH - run: | - echo "/opt/homebrew/bin" >> $GITHUB_PATH - echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH + - name: Locate gfortran + run: which gfortran - - name: Check gfortran installation - run: gfortran --version + - name: Set FC environment variable + run: | + export FC=$(which gfortran) + echo "FC=$FC" >> $GITHUB_ENV + shell: bash - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 @@ -59,14 +60,13 @@ jobs: run: Rscript -e 'install.packages("remotes")' - name: Install package dependencies - run: Rscript -e 'install.packages(c("smacof", "basicspace", "vegan"), dependencies = TRUE)' + run: Rscript -e 'install.packages(c("smacof" "vegan"), dependencies = TRUE)' - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' - - name: Install other R package dependencies run: Rscript -e 'install.packages(c("rjags", "ggplot2", "knitr"))' From 89f4f0f87ae8aaaa90f33c09d329d31a2ef5c9cf Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 01:54:23 +0100 Subject: [PATCH 17/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index c40240d..02a5165 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -73,8 +73,8 @@ jobs: - name: Install rcmdcheck package run: Rscript -e 'install.packages("rcmdcheck")' - - name: Check - run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' + # - name: Check + # run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' - name: Test (optional) run: Rscript -e 'devtools::test()' From edb38ab390ccfe1c6400ed253a8e44f227af530d Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 01:59:21 +0100 Subject: [PATCH 18/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 02a5165..e6abd9f 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -33,14 +33,13 @@ jobs: - name: Install gcc (includes gfortran) run: brew install gcc - - name: Locate gfortran - run: which gfortran - - - name: Set FC environment variable + - name: Ensure gfortran is in PATH run: | - export FC=$(which gfortran) - echo "FC=$FC" >> $GITHUB_ENV - shell: bash + echo "/opt/homebrew/bin" >> $GITHUB_PATH + echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH + + - name: Verify gfortran installation + run: which gfortran - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 @@ -60,7 +59,7 @@ jobs: run: Rscript -e 'install.packages("remotes")' - name: Install package dependencies - run: Rscript -e 'install.packages(c("smacof" "vegan"), dependencies = TRUE)' + run: Rscript -e 'install.packages(c("smacof", "basicspace", "vegan"), dependencies = TRUE)' - name: Install basicspace from GitHub env: @@ -73,8 +72,8 @@ jobs: - name: Install rcmdcheck package run: Rscript -e 'install.packages("rcmdcheck")' - # - name: Check - # run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' + - name: Check + run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' - name: Test (optional) run: Rscript -e 'devtools::test()' From 7414d6ff5f1dcbb0fd0583238bff26a9f264a6dd Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 02:12:04 +0100 Subject: [PATCH 19/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index e6abd9f..633dd26 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -63,7 +63,7 @@ jobs: - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' - name: Install other R package dependencies From 20941e875222a99a37f8229456eb563864763cc7 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 02:36:15 +0100 Subject: [PATCH 20/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 77 +++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 633dd26..b78a125 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -14,7 +14,7 @@ on: branches: [ "master" ] permissions: - contents: read + contents: read jobs: build: @@ -27,59 +27,80 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install JAGS on macOS - run: brew install jags + - name: Install system dependencies on macOS + run: | + brew install jags + brew install --cask mactex-no-gui + brew install gfortran + shell: bash - - name: Install gcc (includes gfortran) - run: brew install gcc + - name: Configure Makevars for gfortran + run: | + mkdir -p ~/.R + echo "FC = /opt/homebrew/opt/gcc/bin/gfortran" >> ~/.R/Makevars + echo "F77 = /opt/homebrew/opt/gcc/bin/gfortran" >> ~/.R/Makevars + echo "FLIBS = -L/opt/homebrew/opt/gcc/lib/gcc/current -lgfortran -lquadmath -lm" >> ~/.R/Makevars + shell: bash - - name: Ensure gfortran is in PATH + - name: Set PATH for gfortran run: | echo "/opt/homebrew/bin" >> $GITHUB_PATH echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH + shell: bash - - name: Verify gfortran installation - run: which gfortran + - name: Check gfortran installation + run: | + which gfortran + gfortran --version + shell: bash - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.r-version }} - - name: Install TinyTeX - run: | - Rscript -e "install.packages('tinytex')" - Rscript -e "tinytex::install_tinytex()" - - - name: Set CRAN mirror - run: Rscript -e 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' - shell: /bin/bash -e {0} - - name: Install remotes package - run: Rscript -e 'install.packages("remotes")' + run: | + Rscript -e "install.packages('remotes')" + shell: Rscript {0} - name: Install package dependencies - run: Rscript -e 'install.packages(c("smacof", "basicspace", "vegan"), dependencies = TRUE)' + run: | + Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" + shell: Rscript {0} - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' + run: | + Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" + shell: Rscript {0} - - name: Install other R package dependencies - run: Rscript -e 'install.packages(c("rjags", "ggplot2", "knitr"))' + - name: Set CRAN mirror and install other R package dependencies + env: + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + run: | + Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" + shell: Rscript {0} - name: Install rcmdcheck package - run: Rscript -e 'install.packages("rcmdcheck")' + run: | + Rscript -e "install.packages('rcmdcheck')" + shell: Rscript {0} - - name: Check - run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' + - name: Run R CMD check + env: + PATH: /opt/homebrew/opt/gcc/bin:/opt/homebrew/bin:$PATH + run: | + Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" + shell: Rscript {0} - name: Test (optional) - run: Rscript -e 'devtools::test()' + run: | + Rscript -e "devtools::test()" + shell: Rscript {0} env: - R_LIBS_USER: /Users/runner/work/_temp/Library TZ: UTC - _R_CHECK_SYSTEM_CLOCK_: FALSE + _R_CHECK_SYSTEM_CLOCK_: false NOT_CRAN: true From d70ae3f948a1cf9f4b4dd46d70a667b05962dcfd Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 02:45:57 +0100 Subject: [PATCH 21/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 80 ++++++++++++++----------------------- 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index b78a125..13be004 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -14,7 +14,7 @@ on: branches: [ "master" ] permissions: - contents: read + contents: read jobs: build: @@ -27,80 +27,60 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install system dependencies on macOS - run: | - brew install jags - brew install --cask mactex-no-gui - brew install gfortran - shell: bash + - name: Install JAGS on macOS + run: brew install jags - - name: Configure Makevars for gfortran - run: | - mkdir -p ~/.R - echo "FC = /opt/homebrew/opt/gcc/bin/gfortran" >> ~/.R/Makevars - echo "F77 = /opt/homebrew/opt/gcc/bin/gfortran" >> ~/.R/Makevars - echo "FLIBS = -L/opt/homebrew/opt/gcc/lib/gcc/current -lgfortran -lquadmath -lm" >> ~/.R/Makevars - shell: bash + - name: Install gcc (includes gfortran) + run: brew install gcc - - name: Set PATH for gfortran + - name: Ensure gfortran is in PATH run: | echo "/opt/homebrew/bin" >> $GITHUB_PATH echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH - shell: bash - - name: Check gfortran installation - run: | - which gfortran - gfortran --version - shell: bash + - name: Verify gfortran installation + run: which gfortran - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.r-version }} - - name: Install remotes package + - name: Install TinyTeX run: | - Rscript -e "install.packages('remotes')" - shell: Rscript {0} + Rscript -e "install.packages('tinytex')" + Rscript -e "tinytex::install_tinytex()" + + - name: Set CRAN mirror + run: Rscript -e 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' + shell: /bin/bash -e {0} + + - name: Install remotes package + run: Rscript -e 'install.packages("remotes")' + shell: /bin/bash -e {0} - name: Install package dependencies - run: | - Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" - shell: Rscript {0} + run: Rscript -e 'install.packages(c("smacof", "basicspace", "vegan"), dependencies = TRUE)' - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: | - Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" - shell: Rscript {0} + GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' - - name: Set CRAN mirror and install other R package dependencies - env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" - shell: Rscript {0} + - name: Install other R package dependencies + run: Rscript -e 'install.packages(c("rjags", "ggplot2", "knitr"))' - name: Install rcmdcheck package - run: | - Rscript -e "install.packages('rcmdcheck')" - shell: Rscript {0} + run: Rscript -e 'install.packages("rcmdcheck")' - - name: Run R CMD check - env: - PATH: /opt/homebrew/opt/gcc/bin:/opt/homebrew/bin:$PATH - run: | - Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" - shell: Rscript {0} + - name: Check + run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' - name: Test (optional) - run: | - Rscript -e "devtools::test()" - shell: Rscript {0} + run: Rscript -e 'devtools::test()' env: + R_LIBS_USER: /Users/runner/work/_temp/Library TZ: UTC - _R_CHECK_SYSTEM_CLOCK_: false + _R_CHECK_SYSTEM_CLOCK_: FALSE NOT_CRAN: true From 62797276610ab4235b5a6362839b6e35b66d3691 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 03:02:36 +0100 Subject: [PATCH 22/37] UPDATE --- .github/workflows/mac_r.yml | 4 ++-- .github/workflows/r.yml | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 13be004..2662073 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -60,11 +60,11 @@ jobs: shell: /bin/bash -e {0} - name: Install package dependencies - run: Rscript -e 'install.packages(c("smacof", "basicspace", "vegan"), dependencies = TRUE)' + run: Rscript -e 'install.packages(c("smacof", "vegan", "plyr"), dependencies = TRUE)' - name: Install basicspace from GitHub env: - GITHUB_PAT: ${{ secrets.GITHUB_PAT }} + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' - name: Install other R package dependencies diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index d5822ca..26a774f 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -29,8 +29,12 @@ jobs: - name: Download and install JAGS run: | - Invoke-WebRequest -Uri "https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download" -OutFile "JAGS-4.3.0.exe" - Start-Process -FilePath ".\JAGS-4.3.0.exe" -ArgumentList '/S' -NoNewWindow -Wait + curl -L -o JAGS-4.3.0.exe https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download + if (Test-Path -Path ".\JAGS-4.3.0.exe") { + Start-Process -FilePath ".\JAGS-4.3.0.exe" -ArgumentList '/S' -NoNewWindow -Wait + } else { + Write-Error "Failed to download JAGS installer." + } shell: powershell - name: Add JAGS to PATH From 7c0f6cc08ea3a172b074e4f3e6b90b604072ceab Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 03:20:34 +0100 Subject: [PATCH 23/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 73 ++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 2662073..3ac8ded 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -14,7 +14,7 @@ on: branches: [ "master" ] permissions: - contents: read + contents: read jobs: build: @@ -27,60 +27,67 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install JAGS on macOS - run: brew install jags - - - name: Install gcc (includes gfortran) - run: brew install gcc - - - name: Ensure gfortran is in PATH + - name: Install system dependencies on macOS run: | - echo "/opt/homebrew/bin" >> $GITHUB_PATH - echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH + brew install jags + brew install --cask mactex-no-gui + brew install gfortran + shell: bash - - name: Verify gfortran installation - run: which gfortran + - name: Create symbolic link for gfortran + run: | + sudo mkdir -p /opt/R/arm64/bin + sudo ln -s $(which gfortran) /opt/R/arm64/bin/gfortran + shell: bash - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.r-version }} - - name: Install TinyTeX - run: | - Rscript -e "install.packages('tinytex')" - Rscript -e "tinytex::install_tinytex()" - - - name: Set CRAN mirror - run: Rscript -e 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' - shell: /bin/bash -e {0} - - name: Install remotes package - run: Rscript -e 'install.packages("remotes")' - shell: /bin/bash -e {0} + run: | + Rscript -e "install.packages('remotes')" + shell: Rscript {0} - name: Install package dependencies - run: Rscript -e 'install.packages(c("smacof", "vegan", "plyr"), dependencies = TRUE)' + run: | + Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" + shell: Rscript {0} - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' + run: | + Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" + shell: Rscript {0} - - name: Install other R package dependencies - run: Rscript -e 'install.packages(c("rjags", "ggplot2", "knitr"))' + - name: Set CRAN mirror and install other R package dependencies + env: + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + run: | + Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" + shell: Rscript {0} - name: Install rcmdcheck package - run: Rscript -e 'install.packages("rcmdcheck")' + run: | + Rscript -e "install.packages('rcmdcheck')" + shell: Rscript {0} - - name: Check - run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' + - name: Run R CMD check + env: + PATH: /opt/homebrew/opt/gcc/bin:/opt/homebrew/bin:$PATH + run: | + Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" + shell: Rscript {0} - name: Test (optional) - run: Rscript -e 'devtools::test()' + run: | + Rscript -e "devtools::test()" + shell: Rscript {0} env: - R_LIBS_USER: /Users/runner/work/_temp/Library TZ: UTC - _R_CHECK_SYSTEM_CLOCK_: FALSE + _R_CHECK_SYSTEM_CLOCK_: false NOT_CRAN: true + From 6ff9fef88d478b134c5d012f3e7886f8b5847c50 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 03:39:32 +0100 Subject: [PATCH 24/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 3ac8ded..05f8a8c 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -91,3 +91,83 @@ jobs: _R_CHECK_SYSTEM_CLOCK_: false NOT_CRAN: true + build-windows: + runs-on: windows-latest + strategy: + matrix: + os: [windows-latest] + r-version: ['4.1.1'] + + steps: + - uses: actions/checkout@v4 + + - name: Download and install JAGS + run: | + Invoke-WebRequest -Uri "https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download" -OutFile "JAGS-4.3.0.exe" + if (Test-Path -Path ".\JAGS-4.3.0.exe") { + Start-Process -FilePath ".\JAGS-4.3.0.exe" -ArgumentList '/S' -NoNewWindow -Wait + } else { + Write-Error "Failed to download JAGS installer." + } + shell: powershell + + - name: Add JAGS to PATH + run: | + echo "C:\Program Files\JAGS\JAGS-4.3.0\bin" >> $GITHUB_PATH + shell: cmd + + - name: Verify JAGS installation + run: jags --version + shell: cmd + + - name: Set up R ${{ matrix.r-version }} + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.r-version }} + + - name: Install remotes package + run: | + Rscript -e "install.packages('remotes')" + shell: cmd + + - name: Install CRAN packages including rjags + run: | + Rscript -e "options(repos = 'https://cloud.r-project.org/')" + Rscript -e "install.packages('rjags')" + Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'), dependencies=TRUE)" + shell: cmd + + - name: Install basicspace from GitHub + env: + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + run: | + Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" + shell: cmd + + - name: Set CRAN mirror and install other R package dependencies + env: + GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} + run: | + Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('ggplot2', 'knitr'));" + shell: cmd + + - name: Install rcmdcheck package + run: | + Rscript -e "install.packages('rcmdcheck')" + shell: cmd + + - name: Check + run: | + Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" + shell: cmd + + - name: Test (optional) + run: | + Rscript -e "devtools::test()" + shell: cmd + + env: + TZ: UTC + _R_CHECK_SYSTEM_CLOCK_: false + NOT_CRAN: true + From 907014d20e42e1b02a4471551d7048f789136151 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 03:49:09 +0100 Subject: [PATCH 25/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 05f8a8c..c6110eb 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -126,9 +126,9 @@ jobs: r-version: ${{ matrix.r-version }} - name: Install remotes package - run: | - Rscript -e "install.packages('remotes')" - shell: cmd + run: Rscript -e 'install.packages("remotes")' + shell: /bin/bash -e {0} + - name: Install CRAN packages including rjags run: | From 01c8f1eeed0d325d6ab5f80be4cc6680323da33f Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 04:33:56 +0100 Subject: [PATCH 26/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index c6110eb..77e030b 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -126,9 +126,9 @@ jobs: r-version: ${{ matrix.r-version }} - name: Install remotes package - run: Rscript -e 'install.packages("remotes")' - shell: /bin/bash -e {0} - + run: Rscript -e \"install.packages('remotes')\" + shell: Rscript {0} + - name: Install CRAN packages including rjags run: | From 27586c7c4e34d2dc764979e76d4ee4352ace9ef6 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 04:54:54 +0100 Subject: [PATCH 27/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 77e030b..438b08d 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -46,9 +46,8 @@ jobs: r-version: ${{ matrix.r-version }} - name: Install remotes package - run: | - Rscript -e "install.packages('remotes')" - shell: Rscript {0} + run: Rscript -e 'install.packages("remotes")' + shell: /bin/bash -e {0} - name: Install package dependencies run: | From fa7b888cc74bf7a59336900c1332e198837cb986 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 05:09:46 +0100 Subject: [PATCH 28/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 438b08d..2125048 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -50,16 +50,15 @@ jobs: shell: /bin/bash -e {0} - name: Install package dependencies - run: | - Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'))" - shell: Rscript {0} - + run: Rscript -e 'install.packages(c("smacof", "ellipse", "plyr", "vegan"))' + shell: /bin/bash -e {0} + - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: | - Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" + run: 'Rscript -e "remotes::install_github(\'cran/basicspace\', force = TRUE)"' shell: Rscript {0} + - name: Set CRAN mirror and install other R package dependencies env: From c77a7f91a83a41a99142d496a2cc7b7838bc8d47 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 05:14:42 +0100 Subject: [PATCH 29/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 114 +++++------------------------------- 1 file changed, 14 insertions(+), 100 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 2125048..7139411 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -9,12 +9,12 @@ name: R Package CI for macOS on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] permissions: - contents: read + contents: read jobs: build: @@ -52,120 +52,34 @@ jobs: - name: Install package dependencies run: Rscript -e 'install.packages(c("smacof", "ellipse", "plyr", "vegan"))' shell: /bin/bash -e {0} - + - name: Install basicspace from GitHub env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: 'Rscript -e "remotes::install_github(\'cran/basicspace\', force = TRUE)"' - shell: Rscript {0} - + run: Rscript -e 'remotes::install_github("cran/basicspace", force = TRUE)' + shell: /bin/bash -e {0} - name: Set CRAN mirror and install other R package dependencies env: GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('rjags', 'ggplot2', 'knitr'));" - shell: Rscript {0} + run: Rscript -e 'options(repos = c(CRAN = "https://cloud.r-project.org/")); install.packages(c("rjags", "ggplot2", "knitr"))' + shell: /bin/bash -e {0} - name: Install rcmdcheck package - run: | - Rscript -e "install.packages('rcmdcheck')" - shell: Rscript {0} + run: Rscript -e 'install.packages("rcmdcheck")' + shell: /bin/bash -e {0} - name: Run R CMD check env: PATH: /opt/homebrew/opt/gcc/bin:/opt/homebrew/bin:$PATH - run: | - Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" - shell: Rscript {0} - - - name: Test (optional) - run: | - Rscript -e "devtools::test()" - shell: Rscript {0} - - env: - TZ: UTC - _R_CHECK_SYSTEM_CLOCK_: false - NOT_CRAN: true - - build-windows: - runs-on: windows-latest - strategy: - matrix: - os: [windows-latest] - r-version: ['4.1.1'] - - steps: - - uses: actions/checkout@v4 - - - name: Download and install JAGS - run: | - Invoke-WebRequest -Uri "https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.0.exe/download" -OutFile "JAGS-4.3.0.exe" - if (Test-Path -Path ".\JAGS-4.3.0.exe") { - Start-Process -FilePath ".\JAGS-4.3.0.exe" -ArgumentList '/S' -NoNewWindow -Wait - } else { - Write-Error "Failed to download JAGS installer." - } - shell: powershell - - - name: Add JAGS to PATH - run: | - echo "C:\Program Files\JAGS\JAGS-4.3.0\bin" >> $GITHUB_PATH - shell: cmd - - - name: Verify JAGS installation - run: jags --version - shell: cmd - - - name: Set up R ${{ matrix.r-version }} - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.r-version }} - - - name: Install remotes package - run: Rscript -e \"install.packages('remotes')\" - shell: Rscript {0} - - - - name: Install CRAN packages including rjags - run: | - Rscript -e "options(repos = 'https://cloud.r-project.org/')" - Rscript -e "install.packages('rjags')" - Rscript -e "install.packages(c('smacof', 'ellipse', 'plyr', 'vegan'), dependencies=TRUE)" - shell: cmd - - - name: Install basicspace from GitHub - env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: | - Rscript -e "remotes::install_github('cran/basicspace', force = TRUE)" - shell: cmd - - - name: Set CRAN mirror and install other R package dependencies - env: - GITHUB_PAT: ${{ secrets.MY_GITHUB_PAT }} - run: | - Rscript -e "options(repos = c(CRAN = 'https://cloud.r-project.org/')); install.packages(c('ggplot2', 'knitr'));" - shell: cmd - - - name: Install rcmdcheck package - run: | - Rscript -e "install.packages('rcmdcheck')" - shell: cmd - - - name: Check - run: | - Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" - shell: cmd + run: Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")' + shell: /bin/bash -e {0} - name: Test (optional) - run: | - Rscript -e "devtools::test()" - shell: cmd + run: Rscript -e 'devtools::test()' + shell: /bin/bash -e {0} env: TZ: UTC _R_CHECK_SYSTEM_CLOCK_: false NOT_CRAN: true - From fd922a735341d23c51b42af99d66b738e3068b29 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 05:34:23 +0100 Subject: [PATCH 30/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 7139411..22e71de 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -39,6 +39,14 @@ jobs: sudo mkdir -p /opt/R/arm64/bin sudo ln -s $(which gfortran) /opt/R/arm64/bin/gfortran shell: bash + + - name: Verify gfortran installation + run: which gfortran + shell: bash + + - name: Check gfortran version + run: gfortran --version + shell: bash - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 From 5a51d63b0c9a14fea67118de746313fe15b23bce Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 05:49:05 +0100 Subject: [PATCH 31/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 22e71de..9a42d30 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -31,21 +31,29 @@ jobs: run: | brew install jags brew install --cask mactex-no-gui - brew install gfortran + brew install gcc + shell: bash + + - name: Check for gfortran in common paths + run: | + if [ -x "/opt/homebrew/bin/gfortran" ]; then + echo "Found gfortran in /opt/homebrew/bin" + elif [ -x "/usr/local/bin/gfortran" ]; then + echo "Found gfortran in /usr/local/bin" + else + echo "gfortran not found" + exit 1 + fi shell: bash - name: Create symbolic link for gfortran run: | sudo mkdir -p /opt/R/arm64/bin - sudo ln -s $(which gfortran) /opt/R/arm64/bin/gfortran + sudo ln -sf $(which gfortran) /opt/R/arm64/bin/gfortran shell: bash - name: Verify gfortran installation - run: which gfortran - shell: bash - - - name: Check gfortran version - run: gfortran --version + run: which gfortran && gfortran --version shell: bash - name: Set up R ${{ matrix.r-version }} From 69c403c2186695d8edf7060720ce7ae98b0d4e54 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 05:57:43 +0100 Subject: [PATCH 32/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 9a42d30..4ba6784 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -40,6 +40,9 @@ jobs: echo "Found gfortran in /opt/homebrew/bin" elif [ -x "/usr/local/bin/gfortran" ]; then echo "Found gfortran in /usr/local/bin" + elif [ -x "/opt/homebrew/opt/gcc/bin/gfortran" ]; then + echo "Found gfortran in /opt/homebrew/opt/gcc/bin" + echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH else echo "gfortran not found" exit 1 From 570d88c356e4b9f2cd046d0af3e8118735ff7b8d Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 15:18:19 +0100 Subject: [PATCH 33/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 4ba6784..c0dad2b 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -49,12 +49,14 @@ jobs: fi shell: bash - - name: Create symbolic link for gfortran + - name: Adjust gfortran library paths run: | - sudo mkdir -p /opt/R/arm64/bin - sudo ln -sf $(which gfortran) /opt/R/arm64/bin/gfortran + if [ -d "/opt/homebrew/opt/gcc" ]; then + sudo ln -sf /opt/homebrew/opt/gcc/lib/gcc /opt/R/arm64/gfortran/lib/gcc + sudo ln -sf /opt/homebrew/opt/gcc/lib /opt/R/arm64/gfortran/lib + fi shell: bash - + - name: Verify gfortran installation run: which gfortran && gfortran --version shell: bash @@ -64,6 +66,12 @@ jobs: with: r-version: ${{ matrix.r-version }} + - name: Verify Rscript is available + run: | + which Rscript + Rscript --version + shell: bash + - name: Install remotes package run: Rscript -e 'install.packages("remotes")' shell: /bin/bash -e {0} From e138c516ffe1bc0dddead352440b1cb873c78d0a Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 16:35:33 +0100 Subject: [PATCH 34/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index c0dad2b..8166669 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -52,6 +52,7 @@ jobs: - name: Adjust gfortran library paths run: | if [ -d "/opt/homebrew/opt/gcc" ]; then + sudo mkdir -p /opt/R/arm64/gfortran/lib/gcc sudo ln -sf /opt/homebrew/opt/gcc/lib/gcc /opt/R/arm64/gfortran/lib/gcc sudo ln -sf /opt/homebrew/opt/gcc/lib /opt/R/arm64/gfortran/lib fi @@ -110,3 +111,4 @@ jobs: TZ: UTC _R_CHECK_SYSTEM_CLOCK_: false NOT_CRAN: true + From 3cca3944de31628a592c6cd8fd8cae2a91f8aaec Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 17:36:02 +0100 Subject: [PATCH 35/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index 8166669..ebe77a1 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -58,21 +58,29 @@ jobs: fi shell: bash - - name: Verify gfortran installation - run: which gfortran && gfortran --version + - name: Add Rscript to PATH + run: | + if [ -x "/Library/Frameworks/R.framework/Resources/bin/Rscript" ]; then + echo "/Library/Frameworks/R.framework/Resources/bin" >> $GITHUB_PATH + elif [ -x "/usr/local/bin/Rscript" ]; then + echo "/usr/local/bin" >> $GITHUB_PATH + else + echo "Rscript not found, exiting." + exit 1 + fi shell: bash - - name: Set up R ${{ matrix.r-version }} - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.r-version }} - - name: Verify Rscript is available run: | which Rscript Rscript --version shell: bash + - name: Set up R ${{ matrix.r-version }} + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.r-version }} + - name: Install remotes package run: Rscript -e 'install.packages("remotes")' shell: /bin/bash -e {0} @@ -112,3 +120,4 @@ jobs: _R_CHECK_SYSTEM_CLOCK_: false NOT_CRAN: true + From f3980fa7c6f0c91eab1b4f5eaca4e7c93fcaf238 Mon Sep 17 00:00:00 2001 From: David Liao Date: Mon, 19 Aug 2024 18:14:38 +0100 Subject: [PATCH 36/37] Update mac_r.yml --- .github/workflows/mac_r.yml | 43 +------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/.github/workflows/mac_r.yml b/.github/workflows/mac_r.yml index ebe77a1..9e3bb0e 100644 --- a/.github/workflows/mac_r.yml +++ b/.github/workflows/mac_r.yml @@ -34,48 +34,6 @@ jobs: brew install gcc shell: bash - - name: Check for gfortran in common paths - run: | - if [ -x "/opt/homebrew/bin/gfortran" ]; then - echo "Found gfortran in /opt/homebrew/bin" - elif [ -x "/usr/local/bin/gfortran" ]; then - echo "Found gfortran in /usr/local/bin" - elif [ -x "/opt/homebrew/opt/gcc/bin/gfortran" ]; then - echo "Found gfortran in /opt/homebrew/opt/gcc/bin" - echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH - else - echo "gfortran not found" - exit 1 - fi - shell: bash - - - name: Adjust gfortran library paths - run: | - if [ -d "/opt/homebrew/opt/gcc" ]; then - sudo mkdir -p /opt/R/arm64/gfortran/lib/gcc - sudo ln -sf /opt/homebrew/opt/gcc/lib/gcc /opt/R/arm64/gfortran/lib/gcc - sudo ln -sf /opt/homebrew/opt/gcc/lib /opt/R/arm64/gfortran/lib - fi - shell: bash - - - name: Add Rscript to PATH - run: | - if [ -x "/Library/Frameworks/R.framework/Resources/bin/Rscript" ]; then - echo "/Library/Frameworks/R.framework/Resources/bin" >> $GITHUB_PATH - elif [ -x "/usr/local/bin/Rscript" ]; then - echo "/usr/local/bin" >> $GITHUB_PATH - else - echo "Rscript not found, exiting." - exit 1 - fi - shell: bash - - - name: Verify Rscript is available - run: | - which Rscript - Rscript --version - shell: bash - - name: Set up R ${{ matrix.r-version }} uses: r-lib/actions/setup-r@v2 with: @@ -121,3 +79,4 @@ jobs: NOT_CRAN: true + From 34b0014475f74a5ac6bf4295fe846736037ad0f3 Mon Sep 17 00:00:00 2001 From: David Liao Date: Fri, 23 Aug 2024 00:55:41 +0100 Subject: [PATCH 37/37] Create ch3.Rmd --- vignettes/ch3.Rmd | 484 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 484 insertions(+) create mode 100755 vignettes/ch3.Rmd diff --git a/vignettes/ch3.Rmd b/vignettes/ch3.Rmd new file mode 100755 index 0000000..bbc8c54 --- /dev/null +++ b/vignettes/ch3.Rmd @@ -0,0 +1,484 @@ +--- +title: "Similarities and Dissimilarities Data" +# author: "Yen-Chieh Liao" +# date: "`r Sys.Date()`" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Similarities and Dissimilarities Data} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + +## 2.1.2 Example 1: 2009 European Election Study (French Module) + +```{r} +library(asmcjr) +data(franceEES2009) +head(franceEES2009) +``` + +```{r} +library(basicspace) +result.france <- aldmck(franceEES2009, respondent=1, polarity=2, + missing=c(77,88,89), verbose=FALSE) +``` + +```{r warning=TRUE, fig.cap="FIGURE 2.1: Aldrich-McKelvey Scaling of Left-Right Self- Placements of French Respondents (2009 European Election Study)"} +# plot stimuli locations in addition to ideal point density +library(ggplot2) +# plot density of ideal points +plot_resphist(result.france, xlab="Left-Right") +``` + +```{r warning=TRUE, fig.cap="FIGURE 2.2: Aldrich-McKelvey Scaling of Left-Right Placements of French Political Parties (2009 European Election Study)"} +# plot stimuli locations in addition to ideal point density +plot_resphist(result.france, addStim=TRUE, xlab = "Left-Right") + + theme(legend.position="bottom", aspect.ratio=1) + + guides(shape = guide_legend(override.aes = list(size = 4), nrow=3)) + + labs(shape="Party", colour="Party") +``` + +```{r warning=TRUE, fig.cap="FIGURE 2.3: Aldrich-McKelvey Scaling of Left-Right Placements of French Political Parties: Positive Weights (2009 European Election Study)"} +# isolate positive weights +plot_resphist(result.france, addStim=TRUE, weights="positive", + xlab = "Left-Right") + + theme(legend.position="bottom", aspect.ratio=1) + + guides(shape = guide_legend(override.aes = list(size = 4), nrow=3)) + + labs(shape="Party", colour="Party") +``` + +```{r warning=TRUE, fig.cap="FIGURE 2.3: Aldrich-McKelvey Scaling of Left-Right Placements of French Political Parties: Negative Weights (2009 European Election Study)"} +# isolate positive weights +plot_resphist(result.france, addStim=TRUE, + weights="negative", xlab = "Left-Right") + + theme(legend.position="bottom", aspect.ratio=1) + + guides(shape = guide_legend(override.aes = list(size = 4), nrow=3)) + + labs(shape="Party", colour="Party") +``` + + +## 2.1.3 Example 2: 1968 American National Election Study Urban Unrest and Vietnam War Scales + +#### Urban Unrest +Running Bayesian Aldrich-Mckelvey +```{r message=FALSE, warning=FALSE} +# Loading 'nes1968_urbanunrest' +data(nes1968_urbanunrest) +# Creating object with US president left-right dimensions +urban <- as.matrix(nes1968_urbanunrest[,-1]) +# Running Bayesian Aldrich-Mckelvey scaling on President positions +library(basicspace) +result.urb <- aldmck(urban, polarity=2, respondent=5, + missing=c(8,9), verbose=FALSE) +summary(result.urb) +``` +Extracting `vote.choice` Column +```{r message=FALSE, warning=FALSE} +# recode so that only Humphrey, Nixon and Wallace are present +vote <- car:::recode(nes1968_urbanunrest[,1], "3='Humphrey'; 5 = 'Nixon'; 6 = 'Wallace'; else=NA", + as.factor=FALSE) +# Convert vote to factor with appropriate levels +vote <- factor(vote, levels=c("Humphrey", "Nixon", "Wallace")) +``` + + +```{r warning=TRUE, fig.cap="FIGURE 2.5: Aldrich-McKelvey Scaling of Urban Unrest Scale: Candidates and Voters (1968 American National Election Study)"} +# Plot population distribution by vote choice +plot_resphist(result.urb, groupVar=vote, addStim=TRUE, + xlab="Liberal-Conservative") + + theme(legend.position="bottom", aspect.ratio=1) + + guides(shape = guide_legend(override.aes = + list(size = 4, color=c("gray25", "gray50", "gray75"))), + colour = "none") + + xlim(c(-2,2)) + + labs(shape="Candidate") +``` +#### Vietnam War Scales +```{r} +data(nes1968_vietnam) +vietnam <- as.matrix(nes1968_vietnam[,-1]) +# Aldrich-Mckelvey function for vietnam dataset +result.viet <- aldmck(vietnam, polarity=2, respondent=5, + missing=c(8,9), verbose=FALSE) +summary(result.viet) +``` + +```{r warning=TRUE, fig.cap="FIGURE 2.6: Aldrich-McKelvey Scaling of Vietnam War Scale: Candidates and Voters (1968 American National Election Study)"} +# Plot population distribution by vote choice +plot_resphist(result.urb, groupVar=vote, addStim=TRUE, + xlab="Liberal-Conservative") + + theme(legend.position="bottom", aspect.ratio=1) + + guides(shape = guide_legend(override.aes = + list(size = 4, color=c("gray25", "gray50", "gray75"))), + colour = "none") + + xlim(c(-2,2)) + + labs(shape="Candidate") +``` + +```{r} +boot.france <- boot.aldmck(franceEES2009, + polarity=2, respondent=1, missing=c(77,88,89), + verbose=FALSE, boot.args = list(R=100)) +``` + + +```{r warning=TRUE, fig.cap="FIGURE 2.7: Aldrich-McKelvey Scaling of Left-Right Placements of French Political Parties (2009 European Election Study) with Bootstrapped Standard Errors"} +library(ggplot2) +ggplot(boot.france$sumstats, aes(x = idealpt, y = stimulus)) + + geom_point() + + # geom_errorbarh(aes(xmin = lower, xmax = upper), height = 0.2) + + xlab("Left-Right") + + ylab(NULL) + + theme_minimal() + + theme(legend.position = "bottom", aspect.ratio = 1) +``` + + +## 2.2.1 Example 1: 2000 Convention Delegate Study + +```{r} +library(basicspace) +data(CDS2000) +head(CDS2000[,5:8]) +``` +Blackbox syntax of Republican-Democrat left-right scale +```{r} +issues <- as.matrix(CDS2000[,5:14]) +result.repdem <- blackbox(issues, + missing=99, dims=3, minscale=5, verbose=TRUE) +``` +Recode party: Democrats = 1; Republicans = 2 +```{r} +party <- car:::recode(CDS2000[,1], + "1='Democrat'; 2='Republican'; else=NA", + as.factor=TRUE) +``` + + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.8: Basic Space (Blackbox) Scaling of US Party Conven- tion Delegates (2000 Convention Delegate Study)"} +plot_blackbox(result.repdem, dims=c(1,2), groupVar=party, + xlab= "First Dimension\n(Left-Right)", + ylab="Second Dimension") + + theme(legend.position="bottom", aspect.ratio=1) + + guides(shape=guide_legend(override.aes=list(size=4))) + + labs(colour="Party") +``` + +## 2.2.2 Example 2: 2010 Swedish Parliamentary Candidate Survey + +```{r} +library(basicspace) +data(Sweden2010) +head(Sweden2010[,1:8]) +``` +Blacbox Scaling for Sweden issue scale +```{r} +# Extract issues scales and convert to numeric +issues.sweden <- as.matrix(Sweden2010[,7:56]) +mode(issues.sweden) <- "numeric" +# Blacbox syntax for Sweden issue scale +result.sweden <- blackbox(issues.sweden, missing=8, + dims=3, minscale=5, verbose=FALSE) +``` + +```{r} + # change polarity of scores + if(result.sweden$individuals[[1]][13,1] < 0) + result.sweden$individuals[[1]][,1] <- + result.sweden$individuals[[1]][,1] * -1 + result.sweden$fits +``` + +```{r} +result.sweden$stimuli[[1]][16:25,] +``` + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.11: Basic Space (Blackbox) Scaling of 2010 Swedish Parliamentary Candidate Data (Candidates by Party)"} +elected <- as.numeric(Sweden2010[,2]) +party.name.sweden <- as.factor(Sweden2010[,3]) +plot_resphist(result.sweden, groupVar=party.name.sweden, dim=1, + scaleDensity=FALSE) + + facet_wrap(~stimulus, ncol=2) + + theme(legend.position="none") + + scale_color_manual(values=rep("black", 10)) +``` + +Density plot syntax and comparison of defeated/elected candidates + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.12: Basic Space (Blackbox) Scaling of 2010 Swedish Parliamentary Candidate Data (Elected and Defeated Candidates by Party)"} +# Keep only the parties of elected candidates, set others to NA +party.name.sweden[which(elected == 0)] <- NA +plot_resphist(result.sweden, groupVar=party.name.sweden, dim=1, scaleDensity=FALSE) + + facet_wrap(~stimulus, ncol=2) + + theme(legend.position="none") + + scale_color_manual(values=rep("black", 10)) +``` + +## 2.2.3 Estimating Bootstrapped Standard Errors for Black Box Scaling + +#### The 2010 Swedish parliamentary candidate data + +```{r eval=TRUE, include=FALSE} +data(outbb) +``` + +```{r eval=FALSE, include=TRUE} +# Candidate point estimates blackbox scaling +outbb <- boot.blackbox(issues.sweden, missing=8, dims=3, minscale=5, + verbose=FALSE, posStimulus=13) +``` + +Matrix creation for Swedish candidates +```{r} +first.dim <- data.frame( + point = result.sweden$individuals[[3]][,1], + se = apply(outbb[,1,], 1, sd) + ) +first.dim$lower <- with(first.dim, point - 1.96*se) +first.dim$upper <- with(first.dim, point + 1.96*se) +first.dim$elected <- factor(elected, levels=c(0,1), + labels=c("Not Elected", "Elected")) +head(first.dim) +``` + +Plot for the distribution of first dimensions bootstrapped SE + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.13: Basic Space (Blackbox) Scaling of 2010 Swedish Parliamentary Candidate Data with Boostrapped Standard Errors (Elected and Defeated Candidates)"} +ggplot(first.dim, aes(x=se, group=elected)) + + stat_density(geom="line", bw=.005) + + facet_wrap(~elected) + + theme(aspect.ratio=1) + + xlab("Standard Error") + + xlim(c(0,.2)) + + theme_bw() +``` + +To determine whether the difference between the two distributions is statistically significant, we compute a permutation test for the difference in standard errors variances. + +```{r} +# Variance test syntax +library(perm) +levels(first.dim$elected) <- c("No", "Yes") +permTS(se ~ elected, data=first.dim, + alternative="greater", method="exact.mc", + control=permControl(nmc=10^4-1)) + +``` + +## 2.3.1 Example 1: 2000 and 2006 Comparative Study of Elec- toral Systems (Mexican Modules) + +```{r} +data(mexicoCSES2000) +data(mexicoCSES2006) +head(mexicoCSES2000) +``` +Blackbox syntax for two datasets, with data cleaning arguments + +```{r eval=TRUE, include=FALSE} +data(result_2000) +data(result_2006) +``` + +```{r eval=FALSE, include=TRUE} +library(basicspace) +result_2000 <- blackbox_transpose(mexicoCSES2000, missing=99, + dims=3, minscale=5, verbose=TRUE) +result_2006 <- blackbox_transpose(mexicoCSES2006, missing=99, + dims=3, minscale=5, verbose=TRUE) +``` +Multiplying here to avoid negative scores +```{r} +# Extract and transform dimensions for the year 2000 +first.dim.2000 <- -1 * result_2000$stimuli[[2]][, 2] +second.dim.2000 <- result_2000$stimuli[[2]][, 3] + +# Extract and transform dimensions for the year 2006 +first.dim.2006 <- -1 * result_2006$stimuli[[2]][, 2] +second.dim.2006 <- result_2006$stimuli[[2]][, 3] + +# Create a data frame for plotting +plot.df <- data.frame( + dim1 = c(first.dim.2000, first.dim.2006), + dim2 = c(second.dim.2000, second.dim.2006), + year = rep(c(2000, 2006), c(length(first.dim.2000), length(first.dim.2006))), + party = factor(c(rownames(result_2000$stimuli[[2]]), rownames(result_2006$stimuli[[2]]))) +) + +# Add nudge values for adjusting labels in the plot +plot.df$nudge_x <- c(0, 0, 0, 0, 0, -0.125, 0, 0, 0, 0.13, 0, 0, -0.225, 0) +plot.df$nudge_y <- c(-0.05, -0.05, 0.05, -0.05, -0.05, 0, -0.05, -0.05, -0.05, 0.03, 0.05, -0.05, -0.025, 0.05) + +# Display the first few rows of the data frame +head(plot.df) + +``` + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.14: Basic Space (Blackbox Transpose) Scaling of Left- Right Placements of Mexican Political Parties (2000 and 2006 Com- parative Study of Electoral Systems)"} +ggplot(plot.df, aes(x=dim1, y=dim2, group=year)) + + geom_point() + + geom_text(aes(label=party), nudge_y=plot.df$nudge_y, size=3, + nudge_x=plot.df$nudge_x, group=plot.df$year) + + facet_wrap(~year) + + xlim(-.55,1) + + ylim(-.55,1) + + theme_bw() + + labs(x="First Dimension", y="Second Dimension") +``` + +## 2.3.2 Estimating Bootstrapped Standard Errors for Black Box Transpose Scaling +```{r} +rankings <- as.matrix(franceEES2009[,2:9]) +mode(rankings) <- "numeric" +original <- blackbox_transpose(rankings, + missing=c(77,88,89), dims=3, minscale=5, verbose=FALSE) +``` + +```{r} +# Reverse check for the first stimulus +if (original$stimuli[[1]][1,2] > 0) { + original$stimuli[[1]][,2] <- -1 * original$stimuli[[1]][,2] +} + +# Print the fits from the original object +print(original$fits) +``` + +```{r eval=TRUE, include=FALSE} +data(outbbt) +``` + +```{r eval=FALSE, include=TRUE} +outbbt <- boot.blackbox_transpose(rankings, missing=c(77,88,89), + dims=3, minscale=5, verbose=FALSE, R=5) +``` + +```{r} +# Create a data frame for the bootstrapped results +france.boot.bbt <- data.frame( + party = colnames(rankings), + point = original$stimuli[[1]][, 2], + se = apply(outbbt[, 1, ], 1, sd, na.rm = TRUE) +) + +# Calculate the confidence intervals +france.boot.bbt$lower <- with(france.boot.bbt, point - 1.96 * se) +france.boot.bbt$upper <- with(france.boot.bbt, point + 1.96 * se) + +# Display the resulting data frame +france.boot.bbt +``` + +## 2.4 Ordered Optimal Classification +```{r message=FALSE, warning=FALSE} +library(asmcjr) +data(ANES2004_OOC) +issuescales <- ANES2004[,1:14] +head(issuescales) +``` +The command below performs OOC on the 2004 ANES issue scale data in two dimensions: + +```{r message=FALSE, warning=FALSE, include=FALSE} +# devtools::install_github('tzuliu/ooc') +library(ooc) +ooc.result <-ooc(issuescales,dims=2,minvotes=10,lop=0.001, + polarity=c(1,1),iter=25,nv.method="svm.reg",cost=1) +``` + +```{r} +issue.result <- ooc.result$issues.unique + +# Set the row names of issue.result using the column names from issuescales +rownames(issue.result) <- colnames(issuescales) + +# Print selected columns from issue.result +print(issue.result[, c("normVectorAngle2D", "wrongScale", + "correctScale", "errorsNull", "PREScale")]) + +``` + + +## 2.5 Using Anchoring Vignettes +calculate party means and standard deviations across all CHES experts +```{r} +# Load the asmcjr package +library(asmcjr) + +# Load the ches_eu dataset +data(ches_eu) + +# Calculate the column means of sub.europe, ignoring NA values +means <- colMeans(sub.europe, na.rm = TRUE) + +# Calculate the standard deviations of the columns in sub.europe, ignoring NA values +sds2 <- apply(sub.europe, 2, sd, na.rm = TRUE) + +# Convert sub.europe to a matrix +sub.europe <- as.matrix(sub.europe) + +# Ensure the mode of sub.europe is numeric +mode(sub.europe) <- "numeric" + +``` + +Call the blackbox_transpose +```{r} +library(basicspace) +result <- blackbox_transpose(sub.europe,dims=3, + minscale=5,verbose=TRUE) +``` + +```{r} +# Create a data frame europe.dat containing x, y coordinates, means, party names, and types +europe.dat <- data.frame( + x = -result$stimuli[[2]][,2], # Negate the second column of stimuli and assign to x + y = result$stimuli[[2]][,3], # Use the third column of stimuli for y + means = means, # Add the means calculated earlier + party = colnames(sub.europe), # Use the column names of sub.europe as party names + type = car:::recode(means, # Recode means into categories: Left, Moderate, and Right + "lo:3 = 'Left'; 3:7 = 'Moderate'; 7:hi = 'Right'", + as.factor = TRUE) +) + +# Separate europe.dat into two data frames: parties.dat and vignette.dat +parties.dat <- europe.dat[-(1:3), ] # Exclude the first three rows for parties.dat +vignette.dat <- europe.dat[(1:3), ] # Include only the first three rows for vignette.dat + +# Extract fit values from the result object +onedim <- result$fits[1, 3] # Extract the one-dimensional fit value +twodim <- result$fits[2, 3] # Extract the two-dimensional fit value +``` + + + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.16: Result of Blackbox Transpose with Anchoring Vignettes"} +library(ggplot2) +ggplot(parties.dat, aes(x = x, y = y)) + + geom_point(aes(shape = type, color = type), size = 3) + + + scale_color_manual(values = gray.palette(3)) + + theme_bw() + + # Add text labels "A", "B", and "C" to the points in vignette.dat + geom_text(data = vignette.dat, label = c("A", "B", "C"), + show.legend = FALSE, size = 10, color = "black") + + xlab(paste0("First Dimension (fit = ", round(onedim, 1), "%)")) + + ylab(paste0("Second Dimension (fit = ", round(twodim, 1), "%)")) + + theme(legend.position = "bottom", aspect.ratio = 1) + + labs(colour = "Party Group", shape = "Party Group") + +``` + + + +```{r message=FALSE, warning=FALSE, fig.cap="FIGURE 2.17: Result of Blackbox Transpose versus Mean Placementes"} +ggplot(parties.dat, aes(x=x, y=means)) + + geom_smooth(method="loess", color="black", lwd=.5, se=FALSE) + + geom_point(aes(shape=type, color=type), size=3) + + scale_color_manual(values=gray.palette(3)) + + theme_bw() + + xlab("First Dimension Coordinates") + + ylab("Mean Party Placement") + + theme(legend.position="bottom", aspect.ratio=1) + + labs(shape="Party Group", colour="Party Group") +``` +