交互因子时的行间标签

时间:2017-07-19 02:52:11

标签: r plot lm interaction

所以我需要在R中使用// delegation implementation details import kotlin.jvm.JvmClassMappingKt; import kotlin.jvm.internal.MutablePropertyReference1Impl; import kotlin.jvm.internal.Reflection; import kotlin.reflect.KProperty1; // notNull property delegate from stdlib import kotlin.properties.Delegates; import kotlin.properties.ReadWriteProperty; class JavaClass { private final ReadWriteProperty<Object, String> x_delegate = Delegates.INSTANCE.notNull(); private final static KProperty1 x_property = Reflection.mutableProperty1( new MutablePropertyReference1Impl( JvmClassMappingKt.getKotlinClass(JavaClass.class), "x", "<no_signature>")); public String getX() { return x_delegate.getValue(this, x_property); } public void setX(String value) { x_delegate.setValue(this, x_property, value); } } class Usage { public static void main(String[] args) { JavaClass instance = new JavaClass(); instance.setX("new value"); System.out.println(instance.getX()); } } 绘制因子变量的相互作用。我已经能够解决所有问题,除了它的一个重要部分:如何更改被绘制因子的标签。这是一个可复制的示例,显示了该问题:

interplot

一旦我在这里绘制了互动,我就得到了:

enter image description here 现在,我需要能够更改构面中的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标签,以便基本上阅读dummyf2LABEL1。这是我尝试的一种可能的解决方案,但这并没有让我得到我需要的东西:

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) 的方面,因为ggplot2使用了interplot,但也无法让它工作。有什么建议?提前谢谢!

1 个答案:

答案 0 :(得分:0)

您必须修改underlying code。它只是将整数附加到变量名称,而不是级别。

解决方法如下所示:

admin