# Assuming you have conducted a statistical test and obtained p-values
# Significance codes: 0 '' 0.001 '' 0.01 '' 0.05 '.' 0.1 ' ' 1
# Assign p-values to the 'p' variable
p <- c(0.001, 0.01, 0.05, 0.1, 0.2, 0.8)
# Create a function to generate significance codes
get_significance_code <- function(p) {
if (p < 0.001) {
return('*')
} else if (p < 0.01) {
return('')
} else if (p < 0.05) {
return('*')
} else if (p < 0.1) {
return('.')
} else {
return(' ')
}
}
# Apply the function to each p-value and store the significance codes
significance_codes <- sapply(p, get_significance_code)
# Print the p-values and their corresponding significance codes
for (i in seq_along(p)) {
cat("p =", p[i], "\t Significance Code:", significance_codes[i], "\n")
}