Skip to content

Commit

Permalink
Update README and covrpage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheiss committed Jun 19, 2019
1 parent ecb3ae4 commit 5f8c5d0
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 58 deletions.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ usrPackages <- "\\renewcommand*\\familydefault{\\rmdefault}"
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)


[![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2019_06_03-brightgreen.svg)](https://tinyurl.com/y43gpto4)
[![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2019_06_19-brightgreen.svg)](https://tinyurl.com/y43gpto4)
[![codecov](https://codecov.io/gh/datalorax/equatiomatic/branch/master/graph/badge.svg)](https://codecov.io/gh/datalorax/equatiomatic)
<!-- badges: end -->

Expand Down
71 changes: 34 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ status](https://travis-ci.org/datalorax/equatiomatic.svg?branch=master)](https:/
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)

[![Covrpage
Summary](https://img.shields.io/badge/covrpage-Last_Build_2019_06_03-brightgreen.svg)](https://tinyurl.com/y43gpto4)
Summary](https://img.shields.io/badge/covrpage-Last_Build_2019_06_19-brightgreen.svg)](https://tinyurl.com/y43gpto4)
[![codecov](https://codecov.io/gh/datalorax/equatiomatic/branch/master/graph/badge.svg)](https://codecov.io/gh/datalorax/equatiomatic)
<!-- badges: end -->

Expand All @@ -25,8 +25,7 @@ models).
## Installation

equatiomatic is not yet on CRAN. Install the development version from
GitHub
with
GitHub with

``` r
remotes::install_github("datalorax/equatiomatic")
Expand All @@ -49,7 +48,7 @@ mod1 <- lm(mpg ~ cyl + disp, mtcars)
# Give the results to extract_eq
extract_eq(mod1)
#> $$
#> \text{mpg} = \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \epsilon
#> \text{mpg} = \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \epsilon
#> $$
```

Expand All @@ -62,7 +61,7 @@ syntax:
mod2 <- lm(mpg ~ ., mtcars)
extract_eq(mod2)
#> $$
#> \text{mpg} = \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \beta_{3}(\text{hp}) + \beta_{4}(\text{drat}) + \beta_{5}(\text{wt}) + \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs}) + \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \text{mpg} = \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \beta_{3}(\text{hp}) + \beta_{4}(\text{drat}) + \beta_{5}(\text{wt}) + \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs}) + \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> $$
```

Expand All @@ -75,7 +74,7 @@ variables as subscripts:
mod3 <- lm(Sepal.Length ~ Sepal.Width + Species, iris)
extract_eq(mod3)
#> $$
#> \text{Sepal.Length} = \alpha + \beta_{1}(\text{Sepal.Width}) + \beta_{2}(\text{Species}_{\text{versicolor}}) + \beta_{3}(\text{Species}_{\text{virginica}}) + \epsilon
#> \text{Sepal.Length} = \alpha + \beta_{1}(\text{Sepal.Width}) + \beta_{2}(\text{Species}_{\text{versicolor}}) + \beta_{3}(\text{Species}_{\text{virginica}}) + \epsilon
#> $$
```

Expand All @@ -94,7 +93,7 @@ d <- data.frame(cat1 = rep(letters[1:3], 100),
mod4 <- lm(out ~ cont1 + cat2 + cont2 + cat1, d)
extract_eq(mod4)
#> $$
#> \text{out} = \alpha + \beta_{1}(\text{cont1}) + \beta_{2}(\text{cat2}_{\text{B}}) + \beta_{3}(\text{cat2}_{\text{C}}) + \beta_{4}(\text{cont2}) + \beta_{5}(\text{cat1}_{\text{b}}) + \beta_{6}(\text{cat1}_{\text{c}}) + \epsilon
#> \text{out} = \alpha + \beta_{1}(\text{cont1}) + \beta_{2}(\text{cat2}_{\text{B}}) + \beta_{3}(\text{cat2}_{\text{C}}) + \beta_{4}(\text{cont2}) + \beta_{5}(\text{cat1}_{\text{b}}) + \beta_{6}(\text{cat1}_{\text{c}}) + \epsilon
#> $$
```

Expand All @@ -109,11 +108,11 @@ the right-hand side of the equation using `terms_per_line` (defaults to
``` r
extract_eq(mod2, wrap = TRUE)
#> $$
#> \begin{aligned}
#> \begin{aligned}
#> \text{mpg} &= \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \beta_{3}(\text{hp})\ + \\
#> &\quad \beta_{4}(\text{drat}) + \beta_{5}(\text{wt}) + \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs})\ + \\
#> &\quad \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \end{aligned}
#> &\quad \beta_{4}(\text{drat}) + \beta_{5}(\text{wt}) + \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs})\ + \\
#> &\quad \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \end{aligned}
#> $$
```

Expand All @@ -122,28 +121,27 @@ extract_eq(mod2, wrap = TRUE)
``` r
extract_eq(mod2, wrap = TRUE, terms_per_line = 6)
#> $$
#> \begin{aligned}
#> \begin{aligned}
#> \text{mpg} &= \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \beta_{3}(\text{hp}) + \beta_{4}(\text{drat}) + \beta_{5}(\text{wt})\ + \\
#> &\quad \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs}) + \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \end{aligned}
#> &\quad \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs}) + \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \end{aligned}
#> $$
```

<img src="man/figures/README-example-wrap-longer-preview-1.png" width="100%" />

When wrapping, you can change whether the lines end with trailing math
operators like `+` (the default), or if they should begin with them
using `operator_location = "end"` or `operator_location =
"start"`:
using `operator_location = "end"` or `operator_location = "start"`:

``` r
extract_eq(mod2, wrap = TRUE, terms_per_line = 4, operator_location = "start")
#> $$
#> \begin{aligned}
#> \begin{aligned}
#> \text{mpg} &= \alpha + \beta_{1}(\text{cyl}) + \beta_{2}(\text{disp}) + \beta_{3}(\text{hp})\\
#> &\quad + \beta_{4}(\text{drat}) + \beta_{5}(\text{wt}) + \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs})\\
#> &\quad + \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \end{aligned}
#> &\quad + \beta_{4}(\text{drat}) + \beta_{5}(\text{wt}) + \beta_{6}(\text{qsec}) + \beta_{7}(\text{vs})\\
#> &\quad + \beta_{8}(\text{am}) + \beta_{9}(\text{gear}) + \beta_{10}(\text{carb}) + \epsilon
#> \end{aligned}
#> $$
```

Expand All @@ -156,11 +154,11 @@ wrapped in `\text{}`) with `ital_vars = TRUE`:
``` r
extract_eq(mod2, wrap = TRUE, ital_vars = TRUE)
#> $$
#> \begin{aligned}
#> \begin{aligned}
#> mpg &= \alpha + \beta_{1}(cyl) + \beta_{2}(disp) + \beta_{3}(hp)\ + \\
#> &\quad \beta_{4}(drat) + \beta_{5}(wt) + \beta_{6}(qsec) + \beta_{7}(vs)\ + \\
#> &\quad \beta_{8}(am) + \beta_{9}(gear) + \beta_{10}(carb) + \epsilon
#> \end{aligned}
#> &\quad \beta_{4}(drat) + \beta_{5}(wt) + \beta_{6}(qsec) + \beta_{7}(vs)\ + \\
#> &\quad \beta_{8}(am) + \beta_{9}(gear) + \beta_{10}(carb) + \epsilon
#> \end{aligned}
#> $$
```

Expand All @@ -186,8 +184,7 @@ preview(extract_eq(mod1))
![](man/figures/preview.png)

Both `extract_eq()` and `preview()` work with **magrittr** pipes, so you
can do something like
this:
can do something like this:

``` r
library(magrittr) # or library(tidyverse) or any other package that exports %>%
Expand All @@ -209,7 +206,7 @@ You can return actual numeric coefficients instead of Greek letters with
``` r
extract_eq(mod1, use_coefs = TRUE)
#> $$
#> \text{mpg} = 34.66 - 1.59(\text{cyl}) - 0.02(\text{disp}) + \epsilon
#> \text{mpg} = 34.66 - 1.59(\text{cyl}) - 0.02(\text{disp}) + \epsilon
#> $$
```

Expand All @@ -222,7 +219,7 @@ FALSE`:
``` r
extract_eq(mod1, use_coefs = TRUE, fix_signs = FALSE)
#> $$
#> \text{mpg} = 34.66 + -1.59(\text{cyl}) + -0.02(\text{disp}) + \epsilon
#> \text{mpg} = 34.66 + -1.59(\text{cyl}) + -0.02(\text{disp}) + \epsilon
#> $$
```

Expand All @@ -234,12 +231,12 @@ This works in longer wrapped equations:
extract_eq(mod2, wrap = TRUE, terms_per_line = 3,
use_coefs = TRUE, fix_signs = FALSE)
#> $$
#> \begin{aligned}
#> \begin{aligned}
#> \text{mpg} &= 12.3 + -0.11(\text{cyl}) + 0.01(\text{disp})\ + \\
#> &\quad -0.02(\text{hp}) + 0.79(\text{drat}) + -3.72(\text{wt})\ + \\
#> &\quad 0.82(\text{qsec}) + 0.32(\text{vs}) + 2.52(\text{am})\ + \\
#> &\quad 0.66(\text{gear}) + -0.2(\text{carb}) + \epsilon
#> \end{aligned}
#> &\quad -0.02(\text{hp}) + 0.79(\text{drat}) + -3.72(\text{wt})\ + \\
#> &\quad 0.82(\text{qsec}) + 0.32(\text{vs}) + 2.52(\text{am})\ + \\
#> &\quad 0.66(\text{gear}) + -0.2(\text{carb}) + \epsilon
#> \end{aligned}
#> $$
```

Expand All @@ -260,10 +257,10 @@ d <- data.frame(out = sample(0:1, 100, replace = TRUE),
mod5 <- glm(out ~ ., data = d, family = binomial(link = "logit"))
extract_eq(mod5, wrap = TRUE)
#> $$
#> \begin{aligned}
#> \log\left[ \frac { P( \text{out} = \text{1} ) }{ 1 - P( \text{out} = \text{1} ) } \right] &= \alpha + \beta_{1}(\text{cat1}_{\text{b}}) + \beta_{2}(\text{cat1}_{\text{c}}) + \beta_{3}(\text{cat2}_{\text{B}})\ + \\
#> &\quad \beta_{4}(\text{cat2}_{\text{C}}) + \beta_{5}(\text{cont1}) + \beta_{6}(\text{cont2}) + \epsilon
#> \end{aligned}
#> \begin{aligned}
#> \log\left[ \frac { P( \text{out} = \text{1} ) }{ 1 - P( \text{out} = \text{1} ) } \right] &= \alpha + \beta_{1}(\text{cat1}_{\text{b}}) + \beta_{2}(\text{cat1}_{\text{c}}) + \beta_{3}(\text{cat2}_{\text{B}})\ + \\
#> &\quad \beta_{4}(\text{cat2}_{\text{C}}) + \beta_{5}(\text{cont1}) + \beta_{6}(\text{cont2}) + \epsilon
#> \end{aligned}
#> $$
```

Expand Down
Binary file modified man/figures/README-example-basic-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-categorical-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-italics-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-logit-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-preserve-order-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-shortcut-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-wrap-longer-location-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-wrap-longer-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-example-wrap-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-fix-signs-long-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-fix-signs-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-use-coefs-preview-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 36 additions & 20 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Tests and Coverage
================
03 June, 2019 20:27:39
19 June, 2019 15:26:43

- [Coverage](#coverage)
- [Unit Tests](#unit-tests)

This output is created by
[covrpage](https://github.com/metrumresearchgroup/covrpage).
Expand All @@ -10,35 +13,48 @@ This output is created by
Coverage summary is created using the
[covr](https://github.com/r-lib/covr) package.

| Object | Coverage (%) |
| :----------------------------------- | :----------: |
| equatiomatic | 0 |
| [R/extract\_eq.R](../R/extract_eq.R) | 0 |
| [R/utils.R](../R/utils.R) | 0 |
| Object | Coverage (%) |
| :------------------------------------- | :----------: |
| equatiomatic | 99.32 |
| [R/create\_eq.R](../R/create_eq.R) | 98.21 |
| [R/extract\_eq.R](../R/extract_eq.R) | 100.00 |
| [R/extract\_lhs.R](../R/extract_lhs.R) | 100.00 |
| [R/extract\_rhs.R](../R/extract_rhs.R) | 100.00 |
| [R/preview.R](../R/preview.R) | 100.00 |
| [R/print.R](../R/print.R) | 100.00 |
| [R/utils.R](../R/utils.R) | 100.00 |

<br>

## Unit Tests

Unit Test summary is created using the
[testthat](https://github.com/r-lib/testthat)
package.
[testthat](https://github.com/r-lib/testthat) package.

| file | n | time | error | failed | skipped | warning |
| :---------------------------------------- | -: | ----: | ----: | -----: | ------: | ------: |
| [test-basic.R](testthat/test-basic.R) | 2 | 0.014 | 0 | 0 | 0 | 0 |
| [test-preview.R](testthat/test-preview.R) | 1 | 0.415 | 0 | 0 | 0 | 0 |
| file | n | time | error | failed | skipped | warning |
| :---------------------------------------------------------------- | -: | ----: | ----: | -----: | ------: | ------: |
| [test-glm.R](testthat/test-glm.R) | 2 | 0.015 | 0 | 0 | 0 | 0 |
| [test-lm.R](testthat/test-lm.R) | 3 | 0.011 | 0 | 0 | 0 | 0 |
| [test-preview.R](testthat/test-preview.R) | 3 | 1.095 | 0 | 0 | 0 | 0 |
| [test-print.R](testthat/test-print.R) | 2 | 0.005 | 0 | 0 | 0 | 0 |
| [test-utils.R](testthat/test-utils.R) | 8 | 0.009 | 0 | 0 | 0 | 0 |
| [test-wrapping-formatting.R](testthat/test-wrapping-formatting.R) | 10 | 0.038 | 0 | 0 | 0 | 0 |

<details closed>

<summary> Show Detailed Test Results
</summary>
<summary> Show Detailed Test Results </summary>

| file | context | test | status | n | time |
| :-------------------------------------------- | :------ | :--------------------- | :----- | -: | ----: |
| [test-basic.R](testthat/test-basic.R#L13) | basic | extract: default | PASS | 1 | 0.012 |
| [test-basic.R](testthat/test-basic.R#L18) | basic | extract: all variables | PASS | 1 | 0.002 |
| [test-preview.R](testthat/test-preview.R#L12) | preview | preview: texPreview | PASS | 1 | 0.415 |
| file | context | test | status | n | time |
| :------------------------------------------------------------------------ | :---------------------- | :---------------------------------------------- | :----- | -: | ----: |
| [test-glm.R](testthat/test-glm.R#L16_L17) | GLMs | Logistic regression works | PASS | 1 | 0.009 |
| [test-glm.R](testthat/test-glm.R#L24) | GLMs | Unsupported GLMs create a message | PASS | 1 | 0.006 |
| [test-lm.R](testthat/test-lm.R#L11_L12) | Linear models | Simple lm models work | PASS | 3 | 0.011 |
| [test-preview.R](testthat/test-preview.R#L13_L14) | Previewing | Previewing works | PASS | 2 | 1.087 |
| [test-preview.R](testthat/test-preview.R#L23_L28) | Previewing | Previewing stops if texPreview is not installed | PASS | 1 | 0.008 |
| [test-print.R](testthat/test-print.R#L11_L12) | Printing | Equation is printed correctly | PASS | 2 | 0.005 |
| [test-utils.R](testthat/test-utils.R#L9_L11) | Utility functions | Strict mapply\_\* functions work | PASS | 8 | 0.009 |
| [test-wrapping-formatting.R](testthat/test-wrapping-formatting.R#L8_L9) | Wrapping and formatting | Coefficient digits work correctly | PASS | 2 | 0.007 |
| [test-wrapping-formatting.R](testthat/test-wrapping-formatting.R#L26_L27) | Wrapping and formatting | Wrapping works correctly | PASS | 8 | 0.031 |

</details>

Expand All @@ -52,7 +68,7 @@ package.
| Platform | x86\_64-apple-darwin15.6.0 (64-bit) |
| Running | macOS Mojave 10.14.5 |
| Language | en\_US |
| Timezone | America/Los\_Angeles |
| Timezone | America/Denver |

| Package | Version |
| :------- | :------ |
Expand Down

0 comments on commit 5f8c5d0

Please sign in to comment.