R/NewStats_2samples.R
NewStats_2samples.Rd
It plots the two samples and the difference between them with their confidence intervals (CI), based on the two samples being independent or dependent.
NewStats_2samples( x, y, dep = FALSE, conf.level = 0.95, col.x = "blue", col.y = "green3", col.diff = "red", ylab.diff = "Difference" )
x | Sample 1 |
---|---|
y | Sample 2 |
dep | Logical indicating if the samples are dependent (Default is F) |
conf.level | Confidence level for the interval (Default is 0.95) |
col.x | Color to use for sample 1 |
col.y | Color to use for sample 2 |
col.diff | Color to use for the difference |
ylab.diff | Label for the secondary y-axis for the difference |
A ggplot object
The labels of the plot are generic but they can be customised using the labs()
and scale_x_discrete(labels = c())
functions. For the dependent samples case the two means are joined by a line, to indicate the dependency
Cumming, G. (2014). The New Statistics: Why and How - Psychological Science, 25(1): 7-29.
set.seed(101) x = rnorm(20, 15, 7) y = rnorm(20, 10, 5) y1 = rnorm(20,x/1.1,2) NewStats_2samples(x, y, dep = FALSE)NewStats_2samples(x, y1, dep = TRUE)