-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_conditions.Rmd
39 lines (29 loc) · 1.04 KB
/
make_conditions.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
---
title: "``brms:: make_conditions`` Prepare Fully Crossed Conditions"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(brms)
```
#### Description
This is a helper function to prepare fully crossed conditions primarily for use with the conditions
argument of ``marginal_effects``. Automatically creates labels for each row in the ``cond__`` column.
#### Usage
<pre><code>
make_conditions(x, vars, ...)
</code></pre>
#### Arguments
* ``x``: An R object from which to extract the variables that should be part of the conditions.
* ``vars``: Names of the variables that should be part of the conditions.
* ``...``: arguments passed to ``rows2labels``.
#### Details
For factor like variables, all levels are used as conditions. For numeric variables, mean + (-1:1) * SD
are used as conditions.
#### Value
A data.frame where each row indicates a condition.
#### Examples
```{r}
df <- data.frame(x = c("a", "b"), y = rnorm(10))
make_conditions(df, vars = c("x", "y"))
```