''x' must be numeric' error for categorical data

I have a dataset(CypData) in which a variable ($mutation) is categorical, but when trying to make a histogram for this variable like so:
hist(CypData$mutation)
I get an error saying 'x' must be numeric. Making a histogram of $age works fine.

Does anyone know what's going on? I figured this should be same as the variable 'spiecies 'in the iris dataset. Disclaimer: Im very new.

You can't make a histogram for a categorical variable (or "factor" in R terminology), maybe what you really want to make is a column plot of the counts?

library(tidyverse)

iris %>%
    count(Species) %>% 
    ggplot(aes(x = Species, y = n, fill = Species)) +
    geom_col()

Created on 2021-01-14 by the reprex package (v0.3.0.9001)

If this is not what you need, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

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.