facet_grid edit FALSE & TRUE

Hello friends,

I need to change "FALSE" and "TRUE" of the tittle on this geom_point, facet grid, here it is my code:

I attach photos and a spreadsheet. Thanks!

Libro_2 %>%
ggplot(aes(x = Presupuesto, y = InsumoDesc, label = Presupuesto)) +
geom_point(mapping = aes(x = Presupuesto /100, y = InsumoDesc, color = InsumoDesc), size = 4)+
facet_grid(~Subcontratos %in% 278939:232178175)+
xlab("Presupuestos para equipos propios versus contratistas mes X")+
ylab("Insumos mes X")+
ggtitle("Diferencias insumos propios versus insumos contratistas mes X", subtitle = "Visualización diferenciadora")+
theme(axis.text.x = element_text(angle = 90, vjust = 0.1, face = "bold", hjust = 0.9))

I can edit the theme and background

  t <- t + theme(strip.text.x = element_text(size=8, angle=75),
        strip.text.y = element_text(size=12, face="bold"),
        strip.background = element_rect(colour="red", fill="#CCCCFF"))

But I need to change: "FALSE" and "TRUE" texts.

Thanks!

(Extract of the data, available here)
https://docs.google.com/spreadsheets/d/1zf5DCUxJ6Z6QDkbTUnZFM4zWLLNabeSUN3-EvmsFdLA/edit?usp=sharing

Thanks!

Hi @bustosmiguel,

The simplest way is to create a new variable that defines the facet groups and has the labels you want. You are faceting based on the following expression: Subcontratos %in% 278939:232178175, so try creating a variable based on this expression before plotting:

Libro_2 %>%
  mutate(
    facet_var = if_else(Subcontratos %in% 278939:232178175, 'label for TRUE', 'label for FALSE')
  ) %>%
  ...
  facet_grid(~ facet_var) +
  ...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.