-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
README.Rmd
297 lines (209 loc) · 7.51 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
---
output: github_document
---
# report <img src='man/figures/logo.png' align="right" height="139" />
```{r, message=FALSE, warning=FALSE, echo=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
dpi = 300,
fig.path = "man/figures/",
comment = "#",
message = FALSE,
warning = FALSE
)
options(
knitr.kable.NA = "",
digits = 4,
width = 80
)
library(dplyr)
library(report)
```
[![R-CMD-check](https://github.com/easystats/report/workflows/R-CMD-check/badge.svg?branch=main)](https://github.com/easystats/report/actions)
[![CRAN](http://www.r-pkg.org/badges/version/report)](https://cran.r-project.org/package=report)
[![r-universe](https://easystats.r-universe.dev/badges/report)](https://easystats.r-universe.dev/report)
[![downloads](http://cranlogs.r-pkg.org/badges/report)](https://cran.r-project.org/package=report)
[![total](https://cranlogs.r-pkg.org/badges/grand-total/report)](https://cranlogs.r-pkg.org/)
[![stars](https://img.shields.io/github/stars/easystats/report?style=social)](https://github.com/easystats/report/stargazers)
***"From R to your manuscript"***
**report**'s primary goal is to bridge the gap between R's output and the formatted results contained in your manuscript. It automatically produces reports of models and data frames according to **best practices** guidelines (e.g., [APA](https://apastyle.apa.org/)'s style), ensuring **standardization** and **quality** in results reporting.
```{r}
library(report)
model <- lm(Sepal.Length ~ Species, data = iris)
report(model)
```
## Installation
The package is available on `CRAN` and can be downloaded by running:
```{r eval=FALSE}
install.packages("report")
```
If you would instead like to experiment with the development version, you can
download it from `GitHub`:
```{r eval=FALSE}
install.packages("remotes")
remotes::install_github("easystats/report") # You only need to do that once
```
Load the package every time you start R
```{r}
library("report")
```
> **Tip**
>
> **Instead of `library(report)`, use `library(easystats)`.**
> **This will make all features of the easystats-ecosystem available.**
>
> **To stay updated, use `easystats::install_latest()`.**
## Documentation
The package documentation can be found [**here**](https://easystats.github.io/report/).
## Report all the things
<a href=https://easystats.github.io/report/><img src="man/figures/allthethings.jpg" height="60" alt="All the things meme by Allie Brosh" ></a>
### General Workflow
The `report` package works in a two step fashion. First, you create a `report` object with the `report()` function. Then, this report object can be displayed either textually (the default output) or as a table, using `as.data.frame()`. Moreover, you can also access a more digest and compact version of the report using `summary()` on the report object.
[![workflow](man/figures/workflow.png)](https://easystats.github.io/report/)
The `report()` function works on a variety of models, as well as other objects such as dataframes:
```{r, eval=FALSE}
report(iris)
```
```{r echo=FALSE}
print(report(iris), width = 80)
```
These reports nicely work within the [*tidyverse*](https://github.com/tidyverse) workflow:
```{r, eval=FALSE}
iris %>%
select(-starts_with("Sepal")) %>%
group_by(Species) %>%
report() %>%
summary()
```
```{r echo=FALSE}
iris %>%
select(-starts_with("Sepal")) %>%
group_by(Species) %>%
report() %>%
summary() %>%
print(width = 80)
```
### *t*-tests and correlations
Reports can be used to automatically format tests like *t*-tests or correlations.
```{r, eval=FALSE}
report(t.test(mtcars$mpg ~ mtcars$am))
```
```{r echo=FALSE}
t.test(mtcars$mpg ~ mtcars$am) %>%
report() %>%
print(width = 80)
```
As mentioned, you can also create tables with the `as.data.frame()` functions, like for example with this correlation test:
```{r, error=TRUE}
cor.test(iris$Sepal.Length, iris$Sepal.Width) %>%
report() %>%
as.data.frame()
```
### ANOVAs
This works great with ANOVAs, as it includes **effect sizes** and their interpretation.
```{r, eval=FALSE}
aov(Sepal.Length ~ Species, data = iris) %>%
report()
```
```{r echo=FALSE}
aov(Sepal.Length ~ Species, data = iris) %>%
report() %>%
print(width = 80)
```
### Generalized Linear Models (GLMs)
Reports are also compatible with GLMs, such as this **logistic regression**:
```{r, eval=FALSE}
model <- glm(vs ~ mpg * drat, data = mtcars, family = "binomial")
report(model)
```
```{r echo=FALSE}
glm(vs ~ mpg * drat, data = mtcars, family = "binomial") %>%
report() %>%
print(width = 80)
```
### Mixed Models
Mixed models, whose popularity and usage is exploding, can also be reported:
```{r, eval=FALSE}
library(lme4)
model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
report(model)
```
```{r echo=FALSE}
library(lme4)
lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) %>%
report() %>%
print(width = 80)
```
### Bayesian Models
Bayesian models can also be reported using the new [**SEXIT**](https://easystats.github.io/bayestestR/reference/sexit.html) framework, which combines clarity, precision and usefulness.
```{r, eval=FALSE}
library(rstanarm)
model <- stan_glm(mpg ~ qsec + wt, data = mtcars)
report(model)
```
```{r echo=FALSE}
options(mc.cores = parallel::detectCores())
library(rstanarm)
model <- stan_glm(mpg ~ qsec + wt, data = mtcars, refresh = 0, iter = 1000) %>%
report() %>%
print(width = 80)
```
## Other types of reports
### Specific parts
One can, for complex reports, directly access the pieces of the reports:
```{r}
model <- lm(Sepal.Length ~ Species, data = iris)
report_model(model)
report_performance(model)
report_statistics(model)
```
### Report participants' details
This can be useful to complete the **Participants** paragraph of your manuscript.
```{r, eval=FALSE}
data <- data.frame(
"Age" = c(22, 23, 54, 21),
"Sex" = c("F", "F", "M", "M")
)
paste(
report_participants(data, spell_n = TRUE),
"were recruited in the study by means of torture and coercion."
)
```
```{r echo=F}
data <- data.frame(
"Age" = c(22, 23, 54, 21),
"Sex" = c("F", "F", "M", "M")
)
paste(
report_participants(data, spell_n = TRUE),
"were recruited in the study by means of torture and coercion."
) |>
insight::format_message() %>%
cat()
```
### Report sample
Report can also help you create a sample description table (also referred to as **Table 1**).
```{r, eval=FALSE}
report_sample(iris, by = "Species")
```
```{r, echo=FALSE}
knitr::kable(report_sample(iris, by = "Species"))
```
### Report system and packages
Finally, **report** includes some functions to help you write the data analysis paragraph about the tools used.
```{r, eval=FALSE}
report(sessionInfo())
```
```{r echo=FALSE}
report(sessionInfo()) %>%
print(width = 80)
```
## Credits
If you like it, you can put a *star* on this repo, and cite the package as follows:
```{r, citation, comment=""}
citation("report")
```
## Contribute
***report* is a young package in need of affection**. You can easily be a part of the [developing](https://github.com/easystats/report/blob/master/.github/CONTRIBUTING.md) community of this open-source software and improve science! Don't be shy, try to code and submit a pull request (See the [contributing guide](https://github.com/easystats/report/blob/master/.github/CONTRIBUTING.md)). Even if it's not perfect, we will help you make it great!
## Code of Conduct
Please note that the report project is released with a [Contributor Code of Conduct](https://easystats.github.io/report/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.