I am trying to compare the tensile strength of different material weights of material in R. The tensile data is as follows:
tensile <- read.table(text=" Weight Strength Replicate
1 15 7 1
2 15 7 2
3 15 15 3
4 15 11 4
5 15 9 5
6 20 12 1
7 20 17 2
8 20 12 3
9 20 18 4
10 20 18 5
11 25 14 1
12 25 18 2
13 25 18 3
14 25 19 4
15 25 19 5
16 30 19 1
17 30 25 2
18 30 22 3
19 30 19 4
20 30 23 5
21 35 7 1
22 35 10 2
23 35 11 3
24 35 15 4
25 35 11 5", header=TRUE)
The variable Weight
should be regarded as a factor (explanatory/independent variable) for the purpose of this analysis:
tensile$Weight <- factor(tensile$Weight)
I first fitted a one-way ANOVA model to my data:
tensile.aov <- aov(Strength ~ Weight, data = tensile)
According to the ANOVA, there appears to be a difference in the different weights with respect to the response (strength). So I then decided to do pairwise comparisons using the LSD (Least Significant Difference):
LSD.aov(tensile.aov)
However, this LSD function was provided through a separate file, so I'm unfortunately unable to share the code here.
I calculated the LSD for my data and got the following table:
Note that, according to the raw p-values, the pairwise comparisons between the 35 and 15 and 25 and 20 weights are the only ones that are not significantly different from each other at the alpha = 0.05 significance level; the other pairwise comparisons are significantly different. I want to create a letter summary to illustrate this, where groups only have the same letter if they are not significantly different from each other, and groups which do not have the same letter are significantly different from each other:
How can I go about creating such a table in R?
I'm also totally open to a 'manual' solution. By this, I mean manually creating a table using vectors and such. I'm new to R, so I don't have a good grasp on even the most basic aspects.