0
interplot
を使用して因子変数の相互作用をプロットする必要があります。重要な部分を除いてすべてを把握することができました。プロットされた。ここでは、問題を示す複製の例です:因子を相互作用させるときのプロットラベル
set.seed(507)
df <- data.frame(
outcome = sample(1:7, 1000, replace = T),
scale = sample(1:7, 1000, replace = T),
dummy = sample(0:2, 1000, replace = T))
# factor the dummy
df$dummyf <- factor(df$dummy)
# linear model
lm.out <- lm(outcome ~ scale * dummyf, data = df)
# interplot
library(interplot)
interplot(lm.out, "dummyf", "scale", plot = T, hist = F, ci = 0.95)
私は対話をプロットすると、ここで私が得るものです:
は今、私は読むための面でdummyf1
とdummyf2
ラベルを変更できるようにする必要があります本質的にLABEL1
およびLABEL2
。ここに私が試したの可能な解決策はありますが、それは私が必要なものを私に取得されていません。
# possible solution?
levels(df$dummyf)[levels(df$dummyf) == 1] <- "LABEL1"
levels(df$dummyf)[levels(df$dummyf) == 2] <- "LABEL2"
# linear model
lm.out.1 <- lm(outcome ~ scale * dummyf, data = df)
# interplot
library(interplot)
interplot(lm.out, "dummyf", "scale", plot = T, hist = F, ci = 0.95)
interplot
がggplot2
を使用していますが、それはどちらかの仕事を得ることができていないので、私もggplot2
のファセットを変更しようとしました。助言がありますか?前もって感謝します!