Skip to content

Commit

Permalink
Include RMarkdown install in GH Action (#261)
Browse files Browse the repository at this point in the history
* Include RMarkdown install in GH Action

* Add more packages to installation

* Use library calls and native R pipe

* Set up R caching for speed

* Install libcurl in runner

* Add sessioninfo dependency

* Don't include R in caching

* Check removal of condition in action

* Only install needed packages
  • Loading branch information
NeuroShepherd authored May 31, 2024
1 parent c46bb15 commit 92bf23c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Cache R packages
uses: actions/cache@v3
id: cache
with:
path: ${{ github.workspace }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install libcurl
run: |
sudo apt-get install libcurl4-openssl-dev
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2

Expand All @@ -22,6 +34,16 @@ jobs:
with:
r-version: '4.4.0'

- name: Install R Packages
# if: steps.cache.outputs.cache-hit != 'true'
run: |
installed.packages()
dependencies <- c("rmarkdown", "dplyr", "ggplot2", "plotly", "sessioninfo")
needs_installation <- dependencies[!dependencies %in% installed.packages()]
install.packages(needs_installation)
library("rmarkdown")
shell: Rscript {0}

- name: Render and Publish
uses: quarto-dev/quarto-actions/publish@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions plot_trait_evolution.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Participants will then get to **see the skull and beak shape** corresponding to
First we load the required packages and create some objects to compile data on trait evolution for each species.

```{r warning=F, message=FALSE}
require(dplyr)
require(ggplot2) #3.5.1
require(plotly) #4.10.4
library(dplyr)
library(ggplot2) #3.5.1
library(plotly) #4.10.4
set.seed(1)
t <- 0:100 # generate time vector
Expand All @@ -58,7 +58,7 @@ for(spp in spp.files){
# generate trait evolution time-series and compile plotting data
dt <- rbind(dt, data.frame(t,
trait = c(0, rnorm(n = length(t) - 1, sd = sqrt(sig2)) %>% cumsum()),
trait = c(0, rnorm(n = length(t) - 1, sd = sqrt(sig2)) |> cumsum()),
species = species.name))
cols <- c(cols, color)
}
Expand Down

0 comments on commit 92bf23c

Please sign in to comment.