Learn R Programming

broom (version 0.3.4)

tidy.density: tidy a density objet

Description

Given a "density" object, returns a tidy data frame with two columns: points x where the density is estimated, points y for the estimate

Usage

## S3 method for class 'density':
tidy(x, ...)

Arguments

x
an object of class "density"
...
extra arguments (not used)

Value

  • a data frame with "x" and "y" columns

    d <- density(faithful$eruptions, bw = "sj") head(tidy(d))

    library(ggplot2) ggplot(tidy(d), aes(x, y)) + geom_line()

See Also

density