hy9fesh
hy9fesh

Reputation: 661

How do I change the mod2 labels in interact_plot()?

I have the following interaction:

data(iris)
View(iris)

reg <- lm(Sepal.Length ~ Sepal.Width*Petal.Width*Petal.Length, data = iris)

I want to create a plot:

library(interactions)

interact_plot(reg, pred = Sepal.Width, modx = Petal.Width, mod2 = Petal.Length, data = iris, x.label = "Sepal Width", y.label = "Sepal Length", legend.main = c("Petal Width"), mod2.labels = c("Petal Length"))

The problem is that I can't seem to change the Petal.Length variable in my plot to "Petal Length" with the mod2.labels function. Any guidance would be appreciated.

Upvotes: 1

Views: 1777

Answers (1)

Allan Cameron
Allan Cameron

Reputation: 173803

You need to pass a vector of complete labels - one per facet:

interact_plot(reg, pred = Sepal.Width, modx = Petal.Width, 
              mod2 = Petal.Length, data = iris, x.label = "Sepal Width", 
              y.label = "Sepal Length", 
              legend.main = c("Petal Width"),
              mod2.labels = c("Mean of Petal Length - 1 SD",
                              "Mean of Petal Length",
                              "Mean of Petal Length + 1 SD"))

enter image description here

Upvotes: 2

Related Questions