0

Given the following example

iris_fat <- iris %>% mutate(is_fat = factor(ifelse(Sepal.Width * Petal.Width > 6 ,"fat", "not_fat")))
reg <- lm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + is_fat, data = iris_fat)
  GGally::ggcoef(reg)

enter image description here

How can I change the name of the term is_fatnot_fat to something else.

Alex
  • 2,603
  • 4
  • 40
  • 73
  • `GGally::ggcoef(reg)+ labs(y = c("(Intercept)", "is_fat", "Petal.Length", "Petal.Width", "Sepal.Width"))` is not working as expected – Alex Mar 13 '18 at 21:50

1 Answers1

1

My bad on the earlier comment, didn't read it carefully.

ggcoef creates a list, just like the other ggplot functions. The first element, data, is a dataframe in which term maps to the y-axis. If you're curious, try str(test_plot$data) or examine it in RStudio

test_plot <- ggcoef(reg)
test_plot$data$term <- c("(Intercept)", "is_fat", "Petal.Length", "Petal.Width", "Sepal.Width")
Punintended
  • 727
  • 3
  • 7