Learn R Programming

TidyDensity (version 1.5.0)

tidy_mixture_density: Tidy Mixture Data

Description

Create mixture model data and resulting density and line plots.

Usage

tidy_mixture_density(...)

Value

A list object

Arguments

...

The random data you want to pass. Example rnorm(50,0,1) or something like tidy_normal(.mean = 5, .sd = 1)

Author

Steven P. Sanderson II, MPH

Details

This function allows you to make mixture model data. It allows you to produce density data and plots for data that is not strictly of one family or of one single type of distribution with a given set of parameters.

For example this function will allow you to mix say tidy_normal(.mean = 0, .sd = 1) and tidy_normal(.mean = 5, .sd = 1) or you can mix and match distributions.

The output is a list object with three components.

  1. Data

  • input_data (The random data passed)

  • dist_tbl (A tibble of the passed random data)

  • density_tbl (A tibble of the x and y data from stats::density())

  1. Plots

  • line_plot - Plots the dist_tbl

  • dens_plot - Plots the density_tbl

  1. Input Functions

  • input_fns - A list of the functions and their parameters passed to the function itself

Examples

Run this code
output <- tidy_mixture_density(rnorm(100, 0, 1), tidy_normal(.mean = 5, .sd = 1))

output$data

output$plots

output$input_fns

Run the code above in your browser using DataLab