Histogram with a text column

Asked

Viewed 51 times

1

I need to do a histogram. I have the following 3 columns:

  • L courses offered

  • M vacancies offered

  • N filled vacancies

Vacancies offered and filled ok, the problem is that I can not put the data of column L in axis X. I used the command, but I get an error message:

hist(ESCOLA$DESCSERIE, breaks=seq(from=1, to=255), main="CURSOS", 
  xlab="DESCSERIE", ylab="MATRIC")

Error in hist.default(ESCOLA$DESCSERIE, breaks = seq(from = 1, to = 255),  : 
 'x' deve ser numérico
  • 1

    Welcome to Stackoverflow! Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please, take a look at this link and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.

1 answer

2

The histogram is a graph designed to visualize the distribution of numerical variables by the sampling space. You can fulfill the same function with categorical information (as should be the variable L - courses offered).

Creating dummy data to use in the answer

library(tidyverse)
set.seed(123)

escola <- data_frame(
  curso = sample(c("Direito", "Economia", "Estatística", "Serviço Social"), 
                  size = 100, replace = TRUE)
)

To create a bar chart that helps understand the distribution of categorical variables in the sample space with the , just pass the data.frame for the function ggplot() and the variable name for the function aes().

ggplot(escola, aes(curso)) +
  geom_bar()

inserir a descrição da imagem aqui

Browser other questions tagged

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