Double factor in r with letters for differentiation

Asked

Viewed 111 times

1

Dear friends, I’m trying to perform a double factor analysis or two-away Anova. I would like to know how to generate the letters of differentiation between treatments for the two factors. This differentiation is common in scientific articles in which it is usually presented in tables, with the minuscule letters differentiating the means in the column and the uppercase letters in the line.

This is done by following the data I used:

    data <- structure(list(Parcela = c(1, 8, 14, 19, 2, 9, 15, 17, 3, 10, 
13, 18, 4, 6, 12, 20, 5, 7, 11, 16, 40, 35, 29, 23, 39, 34, 30, 
25, 38, 32, 26, 21, 37, 33, 28, 22, 36, 31, 27, 24, 41, 47, 51, 
59, 42, 55, NA, 60, 43, 48, 52, 57, 44, 46, 54, 58, 45, 50, 53, 
56, 80, 71, 67, 62, 79, 73, 68, 64, 78, 72, 69, 61, 77, 74, 70, 
63, 76, 75, 66, 65, 81, 90, 93, 99, 82, 86, 91, 96, 83, 89, 92, 
97, 84, 88, 95, 100, 85, 87, 94, 98, 120, 114, 106, 102, 119, 
111, 110, 101, 118, 115, 109, 103, 117, 113, 108, 105, 116, 112, 
107, 104, 121, 128, 134, 136, 122, 129, 131, 137, 123, 127, 132, 
140, 124, 126, 135, 139, 125, 130, 133, 138, 160, 155, 146, 143, 
159, 154, 148, 142, 158, 152, 150, 145, 157, 153, 147, 141, 156, 
151, 149, 144, 161, 170, 174, 176, 162, 168, 172, 180, 163, 167, 
171, 178, 164, 169, 175, 179, 165, 166, 173, 177, 201, 206, 212, 
219, 202, 207, 215, 217, 203, 209, 211, 218, 204, 210, 213, 216, 
205, 208, 214, 220, 240, 234, 227, 222, 239, 235, 228, 224, 238, 
232, 230, 225, 237, 233, 229, 223, 236, 231, 226, 221, 241, 246, 
254, 260, 242, 247, 251, 256, 243, 250, 255, 257, 244, 248, 253, 
259, 245, 249, 252, 258, 280, 275, 267, 263, 279, 274, 269, 265, 
278, 273, 270, 264, 277, 272, 268, 262, 276, 271, 266, 261, 281, 
286, 294, 299, 282, 289, 295, 297, 283, 287, 292, 300, 284, 288, 
291, 298, 285, 290, 293, 296, 320, 314, 307, 301, 319, 313, 308, 
305, 318, 311, 309, 302, 317, 315, 306, 304, 316, 312, 310, 303, 
321, 327, 335, 337, 322, 326, 332, 340, 323, 328, 333, 336, 324, 
330, 334, 338, 325, 329, 331, 339, 360, 355, 346, 341, 359, 354, 
349, 345, 358, 351, 348, 344, 357, 353, 350, 342, 356, 352, 347, 
343), cul = c("BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", 
"BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", 
"BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", 
"BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", 
"BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", "BRS 1001IPRO", 
"BRS 1001IPRO", "BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", 
"BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", 
"BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", 
"BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", 
"BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", "BRS 1003IPRO", 
"BRS 1003IPRO", "BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", 
"BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", 
"BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", 
"BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", 
"BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", "BRS 1007IPRO", 
"BRS 1007IPRO", "BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", 
"BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", 
"BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", 
"BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", 
"BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", "BRS 1010IPRO", 
"BRS 1010IPRO", "BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", 
"BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", 
"BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", 
"BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", 
"BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", "BRS 1074IPRO", 
"BRS 1074IPRO", "BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", 
"BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", 
"BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", 
"BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", "BRS 413RR", 
"BRS 413RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", 
"BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", 
"BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", 
"BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", "BRS 388RR", 
"BRS 388RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", 
"BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", 
"BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", 
"BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", "BRS 399RR", 
"BRS 399RR", "BRB14-211566", "BRB14-211566", "BRB14-211566", 
"BRB14-211566", "BRB14-211566", "BRB14-211566", "BRB14-211566", 
"BRB14-211566", "BRB14-211566", "BRB14-211566", "BRB14-211566", 
"BRB14-211566", "BRB14-211566", "BRB14-211566", "BRB14-211566", 
"BRB14-211566", "BRB14-211566", "BRB14-211566", "BRB14-211566", 
"BRB14-211566", "BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", 
"BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", 
"BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", 
"BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", "BR11-3381", 
"BR11-3381", "BR12-511", "BR12-511", "BR12-511", "BR12-511", 
"BR12-511", "BR12-511", "BR12-511", "BR12-511", "BR12-511", "BR12-511", 
"BR12-511", "BR12-511", "BR12-511", "BR12-511", "BR12-511", "BR12-511", 
"BR12-511", "BR12-511", "BR12-511", "BR12-511", "BR10-87465", 
"BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", 
"BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", 
"BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", 
"BR10-87465", "BR10-87465", "BR10-87465", "BR10-87465", "BRR12-83021", 
"BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", 
"BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", 
"BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", 
"BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-83021", "BRR12-53050", 
"BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", 
"BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", 
"BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", 
"BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-53050", "BRR12-2497", 
"BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", 
"BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", 
"BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", 
"BRR12-2497", "BRR12-2497", "BRR12-2497", "BRR12-2497", "BR12-4929", 
"BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", 
"BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", 
"BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", 
"BR12-4929", "BR12-4929", "BR12-4929", "BR12-4929", "BR12-10309", 
"BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309", 
"BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309", 
"BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309", 
"BR12-10309", "BR12-10309", "BR12-10309", "BR12-10309"), trat = c("Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", 
"Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Test.", "Test.", "Test.", 
"Test.", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", "Boral 500 SC (1,2)", 
"Boral 500 SC (1,2)", "Boral 500 SC (2,4)", "Boral 500 SC (2,4)", 
"Boral 500 SC (2,4)", "Boral 500 SC (2,4)", "Sencor 480 (0,75)", 
"Sencor 480 (0,75)", "Sencor 480 (0,75)", "Sencor 480 (0,75)", 
"Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", "Sencor 480 (1,5)", 
"Test.", "Test.", "Test.", "Test."), rep = c(1, 2, 3, 4, 1, 2, 
3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 
4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 3, 2, 4, 
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 
2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 
3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 
4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 
2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 
3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 
4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 
2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 
3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 
4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 
2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4), alt = c(87.4, 
95.9, 103.3, 94.2, 94.65, 93.2, 98.95, 87.45, 104.4, 103.4, 102.35, 
97.9, 96.7, 101.3, 97.95, 96.3, 102, 98.35, 98.8, 97.4, 64.05, 
71.8, 69.7, 65.4, 46.5, 37.15, 40.05, 44.2, 95.6, 92.35, 87.8, 
87.3, 93.25, 86.4, 93.4, 79.6, 91.3, 92.35, 90.15, 87.3, 82, 
81.15, 75.65, 85.35, 80.35, 75.45, 73.6, 72.9, 95.1, 84.75, 80.6, 
86.45, 89.8, 81.7, 81.7, 84.55, 92.65, 88.9, 89.7, 82.35, 81.3, 
76.55, 92.7, 79.45, 73.25, 42.6, 72.3, 65.6, 102.15, 97, 102.3, 
94.65, 103.4, 94.1, 98.2, 91.65, 104.25, 98.25, 104.05, 100.45, 
98.35, 106.4, 101.55, 94.9, 98.2, 103.35, 98.3, 101.8, 107.2, 
106.85, 104.45, 97.25, 106.2, 100.3, 99.9, 93, 111.15, 102.2, 
107.85, 98.65, 80.15, 75.35, 80.3, 72.5, 73.65, 78.5, 70.7, 76.95, 
77.55, 81.45, 80.95, 76.5, 78.25, 77.2, 81.5, 79.35, 82.55, 77.75, 
83.05, 79.6, 78.1, 78.8, 85.25, 82.25, 79.05, 76.55, 79, 78.85, 
86.6, 75.8, 86.1, 79.35, 77.6, 80.3, 80.4, 69.5, 81.95, 79.1, 
81.5, 80.6, 56.35, 71.85, 74.1, 63.2, 44.3, 37.1, 44.25, 37.25, 
82.65, 84.85, 78, 95.35, 89.15, 82.05, 90.15, 68.95, 89.85, 80.9, 
78.55, 85.7, 71.45, 65.4, 70.05, 71.45, 55.2, 44.7, 59.3, 45.2, 
80.75, 78.95, 75.25, 79.7, 81.2, 73.85, 84.15, 72.7, 81.2, 88, 
80.05, 71.8, 52.35, 69.5, 56.8, 53.2, 29.2, 41.85, 51.75, 37.35, 
65.45, 65.15, 66.5, 49.4, 75.5, 78.5, 67.9, 60.85, 69.15, 66.7, 
62.9, 63, 86.5, 106.75, 95.2, 99.75, 76.3, 89.35, 90.75, 87.45, 
99.8, 110.3, 98.3, 107.15, 99, 104.25, 95.75, 98.75, 102.15, 
106.9, 104.65, 97.5, 91.4, 86.3, 77.6, 87.4, 77.9, 79.5, 86.55, 
72.6, 89.25, 93.55, 86.15, 84.2, 81.1, 93.85, 77.4, 85.85, 87.15, 
96.45, 78.55, 80.4, 72.1, 70.15, 80.8, 77.15, 54.55, 67.7, 76.65, 
70.45, 76.5, 75.4, 80.65, 80.35, 74.3, 75.15, 79.75, 79.9, 76.25, 
82.45, 77.85, 85.5, 85.95, 90.4, 94.55, 98.3, 84.9, 84.35, 93.75, 
77.7, 92.55, 94.15, 100.05, 102.15, 82.55, 91.65, 96.1, 97.4, 
100.3, 97.85, 93.9, 97.3, 93.65, 112.15, 108.2, 111.4, 94.3, 
97.95, 107, 98.65, 110.9, 112.85, 111.65, 116.45, 100, 109.3, 
109.7, 107.4, 106.55, 113.5, 114, 117.8, 107.4, 114, 112.25, 
111, 105.7, 107, 114.9, 115.4, 112.8, 115.65, 113.35, 111.4, 
108.5, 112.1, 112.55, 113.5, 116.95, 116.65, 121.05, 119.6, 92.1, 
100.15, 100.15, 96.35, 91.2, 104.05, 95.7, 92.9, 104.7, 100.3, 
97.8, 99.1, 97.95, 103.85, 100.15, 101.55, 100.55, 100.3, 94.8, 
99.1)), .Names = c("Parcela", "cul", "trat", "rep", "alt"), row.names = c(NA, 
-340L), class = c("tbl_df", "tbl", "data.frame"))

With this data I performed the following operations:

#setup das variaveis
cul <- as.factor(data$cul)
trat <- as.factor(data$trat)
rep <- as.factor(data$rep)
alt <- data$alt


aovalt <- aov(formula=alt ~ cul+trat+cul:trat, data=data)
model.tables(aovalt, "means")

With the command model.tables I practically get the table I want to get, but I lack the letters that demonstrate the differences between cultivars and treatments.

For such I tried:

tukey <- TukeyHSD(aovalt)
tukey$`cul:trat`[,4]
plot(tukey$`cul:trat`[,4])
HSD.test(cul, trt = alt)

But as it is possible to observe is generated a gigantic comparison list, this below being only a fraction of the list.

BR12-10309:Boral 500 SC (2,4)-BRR12-2497:Boral 500 SC (1,2)
9.580700e-01

In this sample it is easier to observe the objective of my question: In the first line is the comparison between the cultivar "BR12-10309" treated with "Boral 500 SC (2,4)" compared to the average of the cultivar "BRR12-2497" treated with "Boral 500 SC (1,2)" and the value of p "9.580700e-01" much less than 0.05 or significant, so there is a difference between these averages, my question is how to classify this difference with letters, separating which cultivar got the best average in treatment x,y,z and etc... and within each cultivar what the best treatment to be applied to it.

Thank you all.

  • 3

    The code is not reproducible. The command data <- data.frame(var,trat,one,two,three) requires the objects two and three that are not defined. To avoid confusion, I suggest editing the question by replacing the entire first block of data creation with the statement of the command dput(data). And if it is possible to rewrite the question, improving the writing with some well-placed commas and shorter sentences (note that there is not a single end point!), I thank you. It will be easier to understand what the doubt actually is.

1 answer

3


I recommend using the package emmeans vignette Interaction analysis in emmeans:

library(emmeans)
l1 <- emmeans(aovalt, "cul", "trat") # Cria o objeto emmeans no caso de interação
CLD(l1, Letter="abcdefghij") # Pede a exibição com as letras
trat = Boral 500 SC (1,2):
 cul            emmean       SE  df  lower.CL  upper.CL .group      
 BR11-3381     57.9625 2.671402 255  52.70168  63.22332  a          
 BRS 399RR     66.3750 2.671402 255  61.11418  71.63582  ab         
 BRS 1003IPRO  67.7375 2.671402 255  62.47668  72.99832  ab         
 BRB14-211566  69.5875 2.671402 255  64.32668  74.84832  abc        
 BRR12-83021   75.0500 2.671402 255  69.78918  80.31082   bcd       
 BRS 413RR     77.0750 2.671402 255  71.81418  82.33582   bcd       
 BRS 1007IPRO  81.0375 2.671402 255  75.77668  86.29832    cde      
 BRS 388RR     81.1000 2.671402 255  75.83918  86.36082    cde      
 BRS 1010IPRO  82.5000 2.671402 255  77.23918  87.76082    cdef     
 BR10-87465    85.6750 2.671402 255  80.41418  90.93582     defg    
 BRR12-53050   92.3000 2.671402 255  87.03918  97.56082      efgh   
 BRS 1001IPRO  95.2000 2.671402 255  89.93918 100.46082       fghi  
 BR12-511      97.0500 2.671402 255  91.78918 102.31082        ghi  
 BR12-10309    97.1875 2.671402 255  91.92668 102.44832        ghi  
 BRS 1074IPRO 100.3000 2.671402 255  95.03918 105.56082         hija
 BRR12-2497   106.3500 2.671402 255 101.08918 111.61082          ija
 BR12-4929    111.1625 2.671402 255 105.90168 116.42332           ja

For each treatment, he makes the comparisons between the "cul". To display the comparisons without displaying the letters, use:

summary(pairs(l1), infer = c(T,T))
trat = Boral 500 SC (1,2):
 contrast                    estimate       SE  df     lower.CL     upper.CL t.ratio p.value
 BR10-87465 - BR11-3381       27.7125 3.777933 255  14.51235057  40.91264943   7.335  <.0001
 BR10-87465 - BR12-10309     -11.5125 3.777933 255 -24.71264943   1.68764943  -3.047  0.1718
 BR10-87465 - BR12-4929      -25.4875 3.777933 255 -38.68764943 -12.28735057  -6.746  <.0001
 BR10-87465 - BR12-511       -11.3750 3.777933 255 -24.57514943   1.82514943  -3.011  0.1875
 BR10-87465 - BRB14-211566    16.0875 3.777933 255   2.88735057  29.28764943   4.258  0.0033
 BR10-87465 - BRR12-2497     -20.6750 3.777933 255 -33.87514943  -7.47485057  -5.473  <.0001
 BR10-87465 - BRR12-53050     -6.6250 3.777933 255 -19.82514943   6.57514943  -1.754  0.9430

Browser other questions tagged

You are not signed in. Login or sign up in order to post.