I try to execute the tapply
function for several variables at the same time, but with the use of the pairwise.t.test
function. However, I do not succeed.
So, I have to do this:
pairwise.t.test(seguro1$tmp_habilit,seguro1$group,method='bonferroni')
pairwise.t.test(seguro1$estciv,seguro1$group,method='bonferroni')
pairwise.t.test(seguro1$nmultas,seguro1$group,method='bonferroni')
That is, one at a time.
dput
to aid in response:
data=structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20), tmp_habilit = c(20, 21, 25,
25, 18, 23, 9, 12, 15, 14, 15, 10, 8, 7, 11, 10, 7, 9, 1, 3),
estciv = c(3, 3, 3, 2, 2, 1, 3, 2, 1, 2, 1, 3, 2, 2, 1, 2,
2, 1, 3, 1), nmultas = c(1, 0, 2, 3, 2, 2, 6, 4, 3, 2, 5,
5, 4, 13, 15, 9, 6, 10, 8, 5), group = structure(c(2L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L,
3L, 3L, 3L), .Label = c("2", "1", "3"), class = "factor"),
group1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("1",
"2", "3"), class = "factor")), .Names = c("id", "tmp_habilit",
"estciv", "nmultas", "group", "group1"), row.names = c(NA, -20L
), class = "data.frame")
The intent is not to type pairwsise.t.test
multiple times (for each group). Is it possible to apply tapply
to this example?