e_plot_function_limit_range: Limit the range of values from a distribution function

View source: R/e_plot_function_limit_range.R

e_plot_function_limit_rangeR Documentation

Limit the range of values from a distribution function

Description

Limit the range of values from a distribution function

Usage

e_plot_function_limit_range(fun = dnorm, min = -Inf, max = +Inf, ...)

Arguments

fun

function, such as distribution function like dnorm

min

min value to include in range

max

max value to include in range

...

arguments passed to fun

Value

filtered range of the function

Examples


f_dnorm_limit <- e_plot_function_limit_range(dnorm, 0, 2)
f_dnorm_limit(-2:4)

library(ggplot2)
p <- ggplot(data.frame(x = c(-3, 3)), aes(x = x))
p <- p + stat_function(fun = dnorm)
p <- p + stat_function(fun = e_plot_function_limit_range(dnorm, 0, 2)
                     , geom = "area", fill = "blue", alpha = 0.2)
p

erikerhardt/erikmisc documentation built on April 17, 2025, 10:48 a.m.