ProjectMOSAIC / mosaic

Project MOSAIC R package
http://mosaic-web.org/
93 stars 26 forks source link

What does "margin" parameter do in "diffprop"? #747

Open lahvak opened 5 years ago

lahvak commented 5 years ago

One of my students was cutting a pasting code and editing it, changing tally to diffprop, and forgot to remove the margin = TRUE parameter, which produced a strange number. Example:

library(tidyverse)
library(mosaic)
data <- read_csv("https://stats.svsu.edu/~jhlavace/teaching_methods.csv")
#> Parsed with column specification:
#> cols(
#>   method = col_character(),
#>   passed = col_logical()
#> )
diffprop(~passed|method, data = data)
#>   diffprop 
#> -0.1400862
diffprop(~passed|method, data = data, margin = TRUE)
#>   diffprop 
#> -0.0700431

Created on 2019-11-01 by the reprex package (v0.2.1)

What does the margin = TRUE do in diffprop?

rpruim commented 4 years ago

Sorry for missing this when you posted it.

margins = TRUE gets passed along to tally() to get the counts. That ends up creating an extra row in the table. We should either ignore that argument or fail with a useful message. I'm going to consider this a bug.