0

I generated a Violin plot created a Violin plot and used the code:

df1 <- df %>%
  mutate(Model=factor(Model,levels=c("SVM", "Grid_SVM", "MARS", "Grid_Mars", "RF", "Grid_RF"))) # to arrange the variable as per the user wish

ggplot(df1, aes(x = Model, y = RE)) +
  geom_violin(trim=FALSE, fill = "palegreen") +
  geom_boxplot(width = .08, fill = "slateblue2", outlier.color = "slateblue2", outlier.size = 2) + 
  labs(title = "RE Adsorption distribution over testing phase") + xlab("Models") + ylab("RE Adsorption distribution")+ theme_classic() +
  theme(
  plot.title = element_text(size = 12, colour = "black", face = "bold"), #for Main Title
  axis.title.x = element_text(size = 12, colour = "black", face = "bold"), #for axix title
  axis.title.y = element_text(size = 12, colour = "black", face = "bold"),
  axis.text.x = element_text(face="bold", color="darkblue", size=12, angle=0), #for axis tick
  axis.text.y = element_text(face="bold", color="black", size=12, angle=0))

But look at the figure generated, a new violin plot appeared, however, one (Grid-MARS) was in dataset that disappeared why? please describe with the edited code (in the given code) as I am new to R.

1 Answers1

1

The problem is that you misspelled the factor level. This should be right, w/r/t your description:

f1 <- df %>%
  mutate(Model=factor(Model,levels=c("SVM", "Grid_SVM", "MARS", "Grid_MARS", "RF", "Grid_RF")))
mrhd
  • 1,036
  • 7
  • 16