Skip to content

Commit

Permalink
Update README with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
briandk committed Nov 21, 2023
1 parent cf8773d commit 336c2af
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 36 deletions.
60 changes: 45 additions & 15 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,70 @@ knitr::opts_chunk$set(
# granovaGG

<!-- badges: start -->

<!-- badges: end -->

The goal of granovaGG is to ...
The package granovaGG is designed to produce statistical graphics driven by the fundamental questions of analysis of variance.
The graphics granovaGG creates can offer far more visual information than a traditional tabular model summary or significance test.
For an example of how granovaGG can enhance analysis, see [Pruzek and Helmreich (2009)](rmpruzek.com/wp-content/uploads/2011/07/ElementalGraphicsForANOVA.finalJune11.pdf).

## Installation

You can install the development version of granovaGG from [GitHub](https://github.com/) with:
You can install the development version of granovaGG from [GitHub](https://github.com) with:

``` r
# install.packages("devtools")
devtools::install_github("briandk/granovaGG")
```

## Example
## Usage

There are three main functions in this package:

- `granovagg.1w()`: for plotting one-way analysis of variance (ANOVA)

- `granovagg.ds`(): for plotting dependent-sample t-test data

- `granovagg.contr()`: for plotting contrasts

## Examples

This is a basic example which shows you how to solve a common problem:
### `granovagg.1w()`

```{r example}
```{r}
library(granovaGG)
## basic example code
data(poison)
# Note violation of constant variance across groups in following graphic.
granovagg.1w(poison$SurvTime, group = poison$Group, ylab = "Survival Time")
```

What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so:
### `granovagg.ds()`

```{r cars}
summary(cars)
```
```{r}
library(granovaGG)
You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this.
# This example corresponds to case 1b in Pruzek and Helmreich (2009). In this
# graphic we're looking for the effect of Family Treatment on patients with anorexia.
data(anorexia.sub)
granovagg.ds(anorexia.sub,
revc = TRUE,
main = "Assessment Plot for weights to assess\nFamily Therapy treatment for Anorexia Patients",
xlab = "Weight after therapy (lbs.)",
ylab = "Weight before therapy (lbs.)"
)
```

You can also embed plots, for example:
### `granovagg.contr()`

```{r pressure, echo = FALSE}
plot(pressure)
```{r}
data(arousal)
contrasts22 <- data.frame( c(-.5,-.5,.5,.5),
c(-.5,.5,-.5,.5), c(.5,-.5,-.5,.5) )
names(contrasts22) <- c("Drug.A", "Drug.B", "Drug.A.B")
granovagg.contr(arousal, contrasts = contrasts22)
```

In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN.
## FAQs
174 changes: 153 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,179 @@
<!-- badges: start -->
<!-- badges: end -->

The goal of granovaGG is to …
The package granovaGG is designed to produce statistical graphics driven
by the fundamental questions of analysis of variance. The graphics
granovaGG creates can offer far more visual information than a
traditional tabular model summary or significance test. For an example
of how granovaGG can enhance analysis, see [Pruzek and Helmreich
(2009)](rmpruzek.com/wp-content/uploads/2011/07/ElementalGraphicsForANOVA.finalJune11.pdf).

## Installation

You can install the development version of granovaGG from
[GitHub](https://github.com/) with:
[GitHub](https://github.com) with:

``` r
# install.packages("devtools")
devtools::install_github("briandk/granovaGG")
```

## Example
## Usage

This is a basic example which shows you how to solve a common problem:
There are three main functions in this package:

- `granovagg.1w()`: for plotting one-way analysis of variance (ANOVA)

- `granovagg.ds`(): for plotting dependent-sample t-test data

- `granovagg.contr()`: for plotting contrasts

## Examples

### `granovagg.1w()`

``` r
library(granovaGG)
data(poison)

# Note violation of constant variance across groups in following graphic.
granovagg.1w(poison$SurvTime, group = poison$Group, ylab = "Survival Time")
#>
#> By-group summary statistics for your input data (ordered by group means)
#> group group.mean trimmed.mean contrast variance standard.deviation
#> 3 3 0.21 0.21 -0.27 0.00 0.02
#> 9 9 0.23 0.23 -0.24 0.00 0.01
#> 2 2 0.32 0.32 -0.16 0.01 0.08
#> 12 12 0.32 0.32 -0.15 0.00 0.03
#> 6 6 0.33 0.33 -0.14 0.00 0.05
#> 8 8 0.38 0.38 -0.10 0.00 0.06
#> 1 1 0.41 0.41 -0.07 0.00 0.07
#> 7 7 0.57 0.57 0.09 0.02 0.16
#> 10 10 0.61 0.61 0.13 0.01 0.11
#> 11 11 0.67 0.67 0.19 0.07 0.27
#> 5 5 0.81 0.81 0.34 0.11 0.34
#> 4 4 0.88 0.88 0.40 0.03 0.16
#> group.size
#> 3 4
#> 9 4
#> 2 4
#> 12 4
#> 6 4
#> 8 4
#> 1 4
#> 7 4
#> 10 4
#> 11 4
#> 5 4
#> 4 4
#>
#> The following groups are likely to be overplotted
#> group group.mean contrast
#> 3 2 0.32 -0.16
#> 4 12 0.32 -0.15
#> 5 6 0.33 -0.14
#>
#> Below is a linear model summary of your input data
#>
#> Call:
#> lm(formula = score ~ group, data = owp$data)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.32500 -0.04875 0.00500 0.04312 0.42500
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 0.41250 0.07457 5.532 2.94e-06 ***
#> group2 -0.09250 0.10546 -0.877 0.386230
#> group3 -0.20250 0.10546 -1.920 0.062781 .
#> group4 0.46750 0.10546 4.433 8.37e-05 ***
#> group5 0.40250 0.10546 3.817 0.000513 ***
#> group6 -0.07750 0.10546 -0.735 0.467163
#> group7 0.15500 0.10546 1.470 0.150304
#> group8 -0.03750 0.10546 -0.356 0.724219
#> group9 -0.17750 0.10546 -1.683 0.101000
#> group10 0.19750 0.10546 1.873 0.069235 .
#> group11 0.25500 0.10546 2.418 0.020791 *
#> group12 -0.08750 0.10546 -0.830 0.412164
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 0.1491 on 36 degrees of freedom
#> Multiple R-squared: 0.7335, Adjusted R-squared: 0.6521
#> F-statistic: 9.01 on 11 and 36 DF, p-value: 1.986e-07
```

<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />

### `granovagg.ds()`

``` r
library(granovaGG)
## basic example code

# This example corresponds to case 1b in Pruzek and Helmreich (2009). In this
# graphic we're looking for the effect of Family Treatment on patients with anorexia.

data(anorexia.sub)

granovagg.ds(anorexia.sub,
revc = TRUE,
main = "Assessment Plot for weights to assess\nFamily Therapy treatment for Anorexia Patients",
xlab = "Weight after therapy (lbs.)",
ylab = "Weight before therapy (lbs.)"
)
#> Summary Statistics
#> n 17.000
#> Postwt mean 90.494
#> Prewt mean 83.229
#> mean(D = Postwt - Prewt) 7.265
#> SD(D) 7.157
#> Effect Size 1.015
#> r(Postwt, Prewt) 0.538
#> r(Postwt + Prewt, D) 0.546
#> Lower 95% Confidence Interval 10.945
#> Upper 95% Confidence Interval 3.585
#> t (D-bar) 4.185
#> df.t 16.000
#> p-value (t-statistic) 0.001
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.
```

What is special about using `README.Rmd` instead of just `README.md`?
You can include R chunks like so:
<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />

### `granovagg.contr()`

``` r
summary(cars)
#> speed dist
#> Min. : 4.0 Min. : 2.00
#> 1st Qu.:12.0 1st Qu.: 26.00
#> Median :15.0 Median : 36.00
#> Mean :15.4 Mean : 42.98
#> 3rd Qu.:19.0 3rd Qu.: 56.00
#> Max. :25.0 Max. :120.00
data(arousal)
contrasts22 <- data.frame( c(-.5,-.5,.5,.5),
c(-.5,.5,-.5,.5), c(.5,-.5,-.5,.5) )
names(contrasts22) <- c("Drug.A", "Drug.B", "Drug.A.B")
granovagg.contr(arousal, contrasts = contrasts22)
#> [[1]]
```

You’ll still need to render `README.Rmd` regularly, to keep `README.md`
up-to-date. `devtools::build_readme()` is handy for this.
<img src="man/figures/README-unnamed-chunk-4-1.png" width="100%" />

#>
#> [[2]]

<img src="man/figures/README-unnamed-chunk-4-2.png" width="100%" />

#>
#> [[3]]

<img src="man/figures/README-unnamed-chunk-4-3.png" width="100%" />

#>
#> [[4]]
#> Warning in mean.default(response): argument is not numeric or logical:
#> returning NA

You can also embed plots, for example:
#> Warning in mean.default(response): argument is not numeric or logical:
#> returning NA
#> Warning: Removed 10 rows containing missing values (`geom_hline()`).

<img src="man/figures/README-pressure-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-4-4.png" width="100%" />

In that case, don’t forget to commit and push the resulting figure
files, so they display on GitHub and CRAN.
## FAQs
Binary file added man/figures/README-unnamed-chunk-2-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 added man/figures/README-unnamed-chunk-3-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 added man/figures/README-unnamed-chunk-4-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 added man/figures/README-unnamed-chunk-4-2.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 added man/figures/README-unnamed-chunk-4-3.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 added man/figures/README-unnamed-chunk-4-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 336c2af

Please sign in to comment.