I have made a plot using ggplot2 geom_histogram from a data frame. See sample below and link to the ggplot histogram Need to label each geom_vline
ggplot2
geom_histogram
If you need just data it seems layer_data is designed precisely for this :
layer_data
layer_data(p, 1)
It will give you the data of the first layer, same as ggplot_build(p)$data[[1]].
ggplot_build(p)$data[[1]]
Its source code is indeed precisely function (plot, i = 1L) ggplot_build(plot)$data[[i]]
function (plot, i = 1L) ggplot_build(plot)$data[[i]]