Function returns significance stars for p-values, most likely for use in tables that report the results of multiple statistical tests. An empty string is returned for NAs, unless that behaviour is overwritten.

sigstars(p, stars = NULL, pad_html = FALSE, ns = FALSE, return_NAs = FALSE)

Source

Adapted from http://www.sthda.com/english/wiki/elegant-correlation-table-using-xtable-r-package

Arguments

p

A p-value or (more commonly) a vector of p-values

stars

A character vector to change the significance symbols (see details below)

pad_html

Should all results be padded right to the same width with HTML non-breaking spaces?

ns

Logical. Should non-significant values be highlighted as "ns"?

return_NAs

Logical. Should NAs be returned? If not, empty strings are returned instead.

Value

A character vector of significance stars for each p-value, each padded with spaces to be four characters long

Details

Symbols and thresholds are *** p < .001, ** p < .01, * p < .05 and † p < .1. The symbols can be changed by passing a named character vector sorted descendingly to the stars argument. For the default, the argument would be stars <- c(= .1,= 0.05,= 0.01, = 0.001)