View source: R/type_function.R
type_function | R Documentation |
Plot a function
type_function(fun = dnorm, args = list(), n = 101, ...)
fun |
Function of |
args |
List of additional arguments to be passed to |
n |
Number of points to interpolate on the x axis. |
... |
Additional arguments are passed to the |
When using type_function()
in a tinyplot()
call, the x
value indicates
the range of values to plot on the x-axis.
# Plot the normal density
tinyplot(x = -4:4, type = type_function(dnorm))
# Extra arguments for the function to plot
tinyplot(x = -1:10, type = type_function(
fun = dnorm, args = list(mean = 3)
))
# Additional arguments are passed to the `lines()` function.
tinyplot(x = -4:4, type = type_function(
fun = dnorm,
col = "pink", type = "p", pch = 3
))
# Custom function example
# (Here using the `\()` anonymous function syntax introduced in R 4.1.0)
tinyplot(x = -4:4, type = type_function(fun = \(x) 0.5 * exp(-abs(x))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.