Skip to content

Commit

Permalink
Using README.Rmd with Github actions to render on push.
Browse files Browse the repository at this point in the history
  • Loading branch information
edsandorf committed Sep 8, 2023
1 parent 13c15fc commit 5c9b7b2
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 6 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
^\.github$
^test.R$
^.DS_Store$
^README\.Rmd$
36 changes: 36 additions & 0 deletions .github/workflows/render-rmarkdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths: ['README.Rmd']

name: render-rmarkdown

jobs:
render-rmarkdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: r-lib/actions/setup-pandoc@v1

- uses: r-lib/actions/setup-r@v1

- uses: r-lib/actions/setup-renv@v1

- name: Render Rmarkdown files
run: |
RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$'))
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]}
- name: Commit results
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"
git push origin || echo "No changes to commit"
65 changes: 59 additions & 6 deletions README.md → README.Rmd
Original file line number Diff line number Diff line change
@@ -1,23 +1,76 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# spdesign: Designing Stated Preference Experiments

<!-- badges: start -->
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version-last-release/spdesign)](https://cran.r-project.org/package=spdesign)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/spdesign)](http://www.r-pkg.org/pkg/spdesign)
[![R build status](https://github.com/edsandorf/spdesign/workflows/R-CMD-check/badge.svg)](https://github.com/edsandorf/spdesign/actions?workflow=R-CMD-check)
[![Coverage Status](https://codecov.io/github/edsandorf/spdesign/coverage.svg?branch=master)](https://codecov.io/github/edsandorf/spdesign?branch=master)
<!-- badges: end -->

# spdesign: Designing Stated Preference Experiments

Contemporary software commonly used to design stated preference experiments are expensive and the code is closed source. `spdesign` is a free software package with an easy to use interface to make flexible stated preference experimental designs using state-of-the-art methods.

# Installing spdesign
## Installation

The package can be installed from CRAN.

``` r
install.packages("spdesign")
```

A development version of the package can be installed from Github.

`devtools::install_github("edsandorf/spdesign")`
``` r
devtools::install_github("edsandorf/spdesign")
```

## Example

This is a basic example which shows you how to solve a common problem:

```{r example, eval=FALSE}
library(spdesign)
#' Specifying a utility function with 3 attributes and a constant for the
#' SQ alternative. The design has 20 rows.
utility <- list(
alt1 = "b_x1[0.1] * x1[1:5] + b_x2[0.4] * x2[c(0, 1)] + b_x3[-0.2] * x3[seq(0, 1, 0.25)]",
alt2 = "b_x1 * x1 + b_x2 * x2 + b_x3 * x3",
alt3 = "b_sq[0.15] * sq[1]"
)
# Generate designs ----
design <- generate_design(utility,
rows = 20,
model = "mnl",
efficiency_criteria = "d-error",
algorithm = "rsc")
# Add a blocking variable to the design with 4 blocks.
design <- block(design, 2)
summary(design)
```


# Bugs and error reporting
## Bugs and error reporting
All software contains bugs and we would very much like to find these and root them out. If you find a bug or get an error message, please reach out so that we can try and improve the software.

# Acknowledgements
## Acknowledgements
We are grateful to Petr Mariel, Jürgen Meyerhoff and Ainhoa Vega for providing feedback and extensive testing of the package. The package comes with no warranty and the authors cannot be held liable for erros or mistakes resulting from use. The authors acknowledge funding from the European Union’s Horizon 2020 research and innovation program under the Marie Sklodowska-Curie grant INSPiRE (Grant agreement ID: 793163).

0 comments on commit 5c9b7b2

Please sign in to comment.