library(gtools) pvalue = 0.0004 stars.pval(pvalue) #Output: # [1] "***" # attr(,"legend") # [1] "0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1"