Hello, I am trying to do a histogram of height in the dataset diabetes by using R. However, I met a question with it. When I load the code below, it tells me that " 'data' must bee a data frame, or other object coercible by fortify(), not an integer vector". Does anyone know why this error happen and how can I solve it?
library(reprex)
library(ggplot2)
diabetes <- read.csv("https://raw.githubusercontent.com/malcolmbarrett/au-stats412-612-01-reading_data/master/diabetes.csv")
just_height <- diabetes[, "height"]
ggplot(just_height, aes(x = height)) +
geom_histogram()
#> Error: `data` must be a data frame, or other object coercible by `fortify()`, not an integer vector.
Created on 2022-02-04 by the reprex package (v2.0.0)