Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/easystats/report

:scroll: :tada: Automated reporting of objects in R
https://github.com/easystats/report

anovas apa automated-report-generation automatic bayesian describe easystats hacktoberfest manuscript models r r-package report reporting reports rstats scientific statsmodels

Last synced: 14 days ago
JSON representation

:scroll: :tada: Automated reporting of objects in R

Awesome Lists containing this project

README

        

---
output: github_document
---

# report

```{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

All the things meme by Allie Brosh

### 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.