How to remove some concepts in dataframe (NULL perhaps)

Hello,

I hope you are very well, I need help how to eliminate these points or modify the dataframe with NULL´s, so obtain an optimus plot or similar or better.

Thanks!

You can run this:

df <- data.frame(Concepto = c("Gastos", "Personal Embalaje", "Producto poco llamativo", "Catálogo Standard",
"Canje", "Desafío", "Participación Social", "Alianzas",
"Reducir Stock","Reducir Costos de Envío", "-", "-",
"Mentalidad", "Open School", "Características del Prototipo", "-"),
Acción = c("Eliminar", "Eliminar","Eliminar","Eliminar", "Aumentar", "Aumentar", "Aumentar","Aumentar",
"Reducir", "Reducir", "Reducir", "Reducir", "Crear", "Crear", "Crear", "Crear"),
Nota = c(0,0,0,0,10,10,10,10,5,5,5,5,9,9,9,9))

df

ggplot(data = df, aes(x = Concepto, y = Acción)) +
geom_line(aes(color = Acción))+
geom_point(size = 10, aes(color = Acción))+
theme(axis.text.x = element_text(angle = 90, hjust=1,vjust=1, size = 10))

To eliminate that entire section from the plot, you can filter out those records from your data frame prior to plotting.

library(tidyverse)

df <- data.frame(Concepto = c("Gastos", "Personal Embalaje", "Producto poco llamativo", "Catálogo Standard",
                              "Canje", "Desafío", "Participación Social", "Alianzas",
                              "Reducir Stock","Reducir Costos de Envío", "-", "-",
                              "Mentalidad", "Open School", "Características del Prototipo", "-"),
                 Acción = c("Eliminar", "Eliminar","Eliminar","Eliminar", "Aumentar", "Aumentar", "Aumentar","Aumentar",
                            "Reducir", "Reducir", "Reducir", "Reducir", "Crear", "Crear", "Crear", "Crear"),
                 Nota = c(0,0,0,0,10,10,10,10,5,5,5,5,9,9,9,9)) %>%
  filter(Concepto != '-')

3 Likes

Thanks!!!
Please, how can I reorder y axis in alphabetical order?

1 Like

You could make this:

df$Acción <-  factor(df$Acción , levels= c( 'Aumentar', 'Crear', 'Eliminar', 'Reducir'))
#next make the plot

You could also add the following:

scale_y_discrete(limits = rev)
1 Like

This topic was automatically closed 7 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.