-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
111 lines (81 loc) · 3.27 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
output:
github_document:
toc: false
fig_width: 10.08
fig_height: 6
tags: [r, reports]
vignette: >
\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
# circus
```{r, echo = FALSE, results='hide', message=FALSE, warning=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
tidy.opts = list(width.cutoff = 60),
tidy = TRUE,
fig.path = "README-"
)
options(
knitr.kable.NA = "",
digits = 4,
width = 60
)
library(rstanarm)
rstan::rstan_options(auto_write = TRUE)
options(
mc.cores = parallel::detectCores(),
digits = 2
)
```
***The Circus of Monsters!***
`circus` contains a variety fitted models to help the systematic testing of other packages.
## Installation
Run the following:
```{r eval=FALSE, message=FALSE, warning=FALSE}
install.packages("remotes")
remotes::install_github("easystats/circus")
library("circus")
```
## How to use it
You can use the package in your `testthat` block by directly calling the models. However, for it to work on **travis**, it is easier to directly download them from github with the `download_model` in the [`insight`](https://github.com/easystats/insight) package:
```{r eval=FALSE, message=FALSE, warning=FALSE}
test_that("my_function_works", {
testthat::skip_if_not_installed("insight")
testthat::skip_if_not_installed("curl") # to check internet access
testthat::skip_if_offline()
testthat::skip_if_not_installed("httr2") # to download stuff
# model <- circus::lmerMod_1 # Local solution
model <- insight::download_model("lmerMod_1")
testthat::skip_if(is.null(model))
testthat::expect_equal(myFunction(model), 0.333)
})
```
## Contribute
Feel free to add any model you find missing! Any scary creature for the depth of your mind has its place here!
In order to add models, do the following:
1. Add your model-name in the `usethis::use_data()` function (last chunk) in the `README.Rmd`
2. Add documentation for your model in the [`R/data.R/`](https://github.com/easystats/circus/blob/main/R/data.R) file
3. Now fit your model and save it to the data-folder, using `usethis::use_data(<yourmodel>)`.
4. Check and build documentation for the package (to generate the `.rd`-files)
5. Upload following files to github: `/data/<yourmodel.rda>`, `data.R` and `data.rd`.
**Note** When you build or install the package, it is recommended to do so with following build-options: `R CMD INSTALL --no-multiarch --with-keep.source --no-libs --no-data`. Furthermore, when building the documentation, make sure to **not** build the vignettes.
## Sample data
### Illusion Game
```{r ,eval=FALSE}
# Data from Makowski et al., (2023) for the Illusion Game
df <- read.csv("https://raw.githubusercontent.com/RealityBending/IllusionGameValidation/refs/heads/main/data/study1.csv")
df <- df[c("Participant", "Illusion_Type", "Trial", "RT", "Error", "Illusion_Strength", "Illusion_Difference")]
df$RT <- df$RT / 1000
df <- df[df$Illusion_Strength > 0, ]
df <- df[df$Illusion_Type %in% c("Müller-Lyer", "Delboeuf", "Ebbinghaus", "Vertical-Horizontal", "Ponzo"), ]
write.csv(df, "../data/illusiongame.csv", row.names = FALSE)
```
## How to add models
```{r, eval=FALSE, warning=FALSE, message=FALSE, results="hide"}
lm_1 <- lm(mpg ~ wt, data = mtcars)
usethis::use_data(lm_1, overwrite = TRUE)
```