/ / Estrazione dei dati da Tukey HSD in R - r, struttura, estratto

Estrazione di dati da Tukey HSD in R - r, struttura, estratto

Si consideri il seguente pezzo di codice giocattolo (puramente illustrativo):

y <- data.frame(matrix(c(11,12,13,14,113,124,215,219),nrow=4));
y[,2] <- factor(y[,2]);
aov.result <- aov(y$X1 ~ y$X2, data=y);
thsd.result <- TukeyHSD(aov.result); # Produces NaNs but nevermind
fix(thsd.result)

l'ultimo comando (fix) mostra che l'oggetto thsd.result è una struttura contenente un elenco e una struttura nidificata:

structure(list(`df$X2` = structure(c(1, 2, 3, 1, 2, 1, NaN, NaN,
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
NaN, NaN, NaN), .Dim = c(6L, 4L), .Dimnames = list(c("124-113",
"215-113", "219-113", "215-124", "219-124", "219-215"), c("diff",
"lwr", "upr", "p adj")))), .Names = "df$X2", class = c("multicomp",
"TukeyHSD"), orig.call = quote(aov(formula = df$X1 ~ df$X2, data = df)), conf.level =
0.95, ordered = FALSE);

La mia domanda è: come potrei fare per accedere a questa struttura? Cioè Come potrei ad esempio ottenere i nomi .Dimnames costituiti dalle coppie?

risposte:

0 per risposta № 1

intendi in questo modo:

dimnames(thsd.result[[1]])

e questo:

> rownames(thsd.result[[1]])
[1] "124-113" "215-113" "219-113" "215-124" "219-124" "219-215"
> colnames(thsd.result[[1]])
[1] "diff"  "lwr"   "upr"   "p adj"

per ottenere il risultato basta accedervi usando [[]].

Vedi i risultati stampati con:

thsd.result[[1]] e thsd.result[[1]][,1]