You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `groups` argument can be used to group parameters in the table. `groups` must be a named list, where the names of the list elements equal the header of each group, while the values of the list elements equal the parameter names, or the position of the parameters in the table (data frame).
195
+
The `groups` argument can be used to group parameters in the table. `groups` must be a named list, where the names of the list elements equal the header of each group, while the values of the list elements equal the parameter names, or the position of the parameters in the table (data frame). Usually, indexing by position is easier, since the parameter names can be modified during formatting the output.
196
196
197
197
In the following example, we see the names of the parameters in the `Parameter` column, while the rownumbers indicate their position.
198
198
@@ -209,17 +209,17 @@ mp <- model_parameters(model, drop = "^\\(Intercept")
209
209
as.data.frame(mp)
210
210
```
211
211
212
-
Now we create a group named `"Engine"`, which encompasses the parameters `"cyl6"`, `"cyl8"`, `"vs"` and `"hp"`. The `"Interactions"` group includes `"gear4:vs"` and `"gear5:vs"`. The group `"controls"` has the parameters from rows 2, 3 and 7.
212
+
Now we create a group named `"Engine"`, which encompasses the parameters `"cyl6"`, `"cyl8"`, `"vs"` and `"hp"` (rows 5, 6, 4 and 1). The `"Interactions"` group includes `"gear4:vs"` and `"gear5:vs"` (rows 8 and 9). The group `"controls"` has the parameters from rows 2, 3 and 7.
213
213
214
214
Note that the parameters in the table summary are re-ordered according to the order specified in `groups`.
215
215
216
216
```{r}
217
217
# group parameters, either by parameter name or position
218
218
print(mp, groups = list(
219
-
Engine = c("cyl6", "cyl8", "vs", "hp"),
220
-
Interactions = c("gear4:vs", "gear5:vs"),
219
+
Engine = c(5, 6, 4, 1),
220
+
Interactions = c(8, 9),
221
221
Controls = c(2, 3, 7)
222
-
)) # gear 4 and 5, drat
222
+
))
223
223
```
224
224
225
225
If you prefer tables without vertical borders, use the `sep` argument to define the string that is used as border-separator. This argument is passed down to `insight::export_table()`.
@@ -229,8 +229,8 @@ If you prefer tables without vertical borders, use the `sep` argument to define
229
229
print(mp,
230
230
sep = " ",
231
231
groups = list(
232
-
Engine = c("cyl6", "cyl8", "vs", "hp"),
233
-
Interactions = c("gear4:vs", "gear5:vs"),
232
+
Engine = c(5, 6, 4, 1),
233
+
Interactions = c(8, 9),
234
234
Controls = c(2, 3, 7)
235
235
)
236
236
)
@@ -382,6 +382,6 @@ print(tab, table_width = 80)
382
382
383
383
# More advances tables and markdown / HTML formatting
384
384
385
-
The `print_md()` as well as `print_html()` functions can be used to create markdown (for knitting to PDF or Word) and HTML tables.
385
+
The `print_md()` as well as `print_html()` functions can be used to create markdown (for knitting to PDF or Word) and HTML tables, where HTML tables are created using the [**gt**](https://gt.rstudio.com/) package. There is also a `display()` function, which internally calls `print_md()` or `print_html()`, depending on the `format` argument. However, for `display()`, the `format` argument can also be `"tt"` to use the [**tinytable**](https://vincentarelbundock.github.io/tinytable/) package as engine to produce tables. This will create tables in different output formats, depending on the environment where the code is run (e.g. R Markdown, Jupyter Notebook, etc.).
386
386
387
387
Meanwhile, there are a lot of additional packages that allow users to have even more flexibility regarding table layouts. One package we can recommend is the [*modelsummary* package](https://vincentarelbundock.github.io/modelsummary/).
0 commit comments