plotttest | R Documentation |

This function plots the density probability distribution of a Student's (or Welch's) t statistic, with appropriate vertical cutlines at the t value. The p-value and the observed t value are plotted. Although largely customizable, only two arguments are required (the observed t statistic and the degrees of freedom) for a two-tailed t test. The optional argument `tails = "one"`

plots a one-tailed test plot (the tail is on the left or right, depending on the sign of the t statistic).

```
plotttest(
t,
df = t$parameter,
tails = "two",
blank = FALSE,
xmax = "auto",
title = "t Test",
xlabel = "t",
ylabel = "Density of probability\nunder the null hypothesis",
fontfamily = "serif",
colormiddle = "aliceblue",
colorsides = "firebrick3",
colormiddlecurve = "black",
colorsidescurve = "black",
colorcut = "black",
colorplabel = colorsides,
theme = "default",
signifdigitst = 3,
curvelinesize = 0.4,
cutlinesize = curvelinesize
)
```

`t` |
A numeric value indicating the observed t statistic. Alternatively, you can pass an object of class |

`df` |
A numeric value indicating the degrees of freedom. This argument is optional if you are using an |

`tails` |
A character that indicates whether to plot a one ( |

`blank` |
A logical that indicates whether to hide ( |

`xmax` |
A numeric including the maximum for the x-axis. Defaults to |

`title` |
A character or expression indicating a custom title for the plot (optional). |

`xlabel` |
A character or expression indicating a custom title for the x axis (optional). |

`ylabel` |
A character or expression indicating a custom title for the y axis (optional). |

`fontfamily` |
A character indicating the font family of all the titles and labels (e.g. |

`colormiddle` |
A character indicating the color for the "middle" area under the curve (optional). |

`colorsides` |
A character indicating the color for the "side(s)" area(s) under the curve (optional). |

`colormiddlecurve` |
A character indicating the color for the "middle" part of the curve (optional). |

`colorsidescurve` |
A character indicating the color for the "side(s)" part of the curve (optional). |

`colorcut` |
A character indicating the color for the cut line at the observed test statistic (optional). |

`colorplabel` |
A character indicating the color for the label of the p-value (optional). By default, for color consistency, this color is the same as color of |

`theme` |
A character indicating one of the predefined color themes. The themes are |

`signifdigitst` |
A numeric indicating the number of desired significant figures reported for the t label (optional). |

`curvelinesize` |
A numeric indicating the size of the curve line (optional). |

`cutlinesize` |
A numeric indicating the size of the cut line(s) (optional). By default, the size of the curve line is used. |

A plot with the density of probability of t under the null hypothesis, annotated with the observed test statistic and the p-value.

Nils Myszkowski <nmyszkowski@pace.edu>

```
#Making a t test plot with a t value of 2 and df of 10
plotttest(t = 2, df = 10)
#Note that the same can be obtained even quicker with:
plotttest(2,10)
#The same plot without the t or p value
plotttest(2,10, blank = TRUE)
#Plotting a one-tailed test using the "tails" parameter.
plotttest(t = 2, df = 10, tails = "one")
#Using t.test() as an input
test <- t.test(rnorm(10), rnorm(10))
plotttest(test)
#Using cor.test() as an input
test <- cor.test(rnorm(10), rnorm(10))
plotttest(test)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.