estimate_density_groups: Calculate density estimates across groups

Description Usage Arguments Details Value

View source: R/density.R

Description

Estimate densities of x by each level of by.

Usage

1
estimate_density_groups(.data, x, by, limits, ...)

Arguments

.data

A data frame to use for x and by.

x

A variable to estimate density from.

by

A grouping-type variable (e.g., factor) to calculate x densities by.

...

Any further parameters to stats::density().

Details

Given a data.frame (.data) with values in x, estimate the density of x separately for each of the levels of by.

For instance, if by is color with values c("blue","red","green") then compute densities for x separately for blue, red and green.

The return result of this function is a data frame with three columns: x, y and by. The x,y values are the results of estimating density (see estimate_density()) and the value of by is the specific level value from the by variable.

Value

A data.frame with three columns: x, y and by.


steveneschrich/densityplots documentation built on Dec. 23, 2021, 5:32 a.m.