Skip to contents

Obtain variance per group as well as check for the rule of thumb of one group having variance four times bigger than any of the other groups. Variance ratio is calculated as Max / Min.

Usage

nice_var(data, variable, group, criteria = 4)

Arguments

data

The data frame

variable

The dependent variable to be plotted.

group

The group by which to plot the variable.

criteria

Desired threshold if one wants something different than four times the variance.

Examples

# Make the basic table
nice_var(
  data = iris,
  variable = "Sepal.Length",
  group = "Species"
)
#> # A tibble: 1 × 7
#> # Rowwise: 
#>   Variable     Setosa Versicolor Virginica Variance.ratio Criteria Heterosceda…¹
#>   <chr>         <dbl>      <dbl>     <dbl>          <dbl>    <dbl> <lgl>        
#> 1 Sepal.Length  0.124      0.266     0.404            3.3        4 FALSE        
#> # … with abbreviated variable name ¹​Heteroscedastic

# Try on multiple variables
DV <- names(iris[1:4])
var.table <- do.call("rbind", lapply(DV, nice_var,
  data = iris, group = "Species"
))
var.table
#> # A tibble: 4 × 7
#> # Rowwise: 
#>   Variable     Setosa Versicolor Virginica Variance.ratio Criteria Heterosceda…¹
#>   <chr>         <dbl>      <dbl>     <dbl>          <dbl>    <dbl> <lgl>        
#> 1 Sepal.Length  0.124      0.266     0.404            3.3        4 FALSE        
#> 2 Sepal.Width   0.144      0.098     0.104            1.5        4 FALSE        
#> 3 Petal.Length  0.03       0.221     0.305           10.2        4 TRUE         
#> 4 Petal.Width   0.011      0.039     0.075            6.8        4 TRUE         
#> # … with abbreviated variable name ¹​Heteroscedastic