How to count the quantity in variable using boxplot, not the frequency?

Asked

Viewed 27 times

2

I’m trying to create a boxplot of the amount of respirators per state, but when I plot the R counts the frequency of respirators not the amount per state. There I have the following information:

inserir a descrição da imagem aqui

I need the amounts to be summed up, not that he uses the frequency. How can I do this?

Download from the database: https://dados.gov.br/dataset/distribuicao-de-respiradores

Follows script:

distribuicao_respiradores <- read.csv2("~/distribuicao_respiradores.csv", encoding="UTF-8", stringsAsFactors=FALSE)
View(distribuicao_respiradores)
attach(distribuicao_respiradores)

library(ggplot2)

boxplotgraf <- ggplot(distribuicao_respiradores, aes(x=DESTINO, y=QUANTIDADE))

boxplotgraf + geom_boxplot(outlier.color = "red") +
  theme_classic() +
  labs(y="Quantidade") +
  coord_flip()
  • 3

    There is no error in your code, these boxplots are of the quantities. If what you want is only the total per State, boxplots are not for that.

  • 1

    It’s like @Carloseduardolalike commented. Boxplots, are to see the distribution, with medians , quartiles and etcs. I think you want a histogram.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.