Learn R Programming

algebraic.dist (version 0.9.1)

rmap.empirical_dist: Method for obtaining the empirical distribution of a function of the observations of empirical_dist object x.

Description

Method for obtaining the empirical distribution of a function of the observations of empirical_dist object x.

Usage

# S3 method for empirical_dist
rmap(x, g, ...)

Value

An empirical_dist of the transformed observations.

Arguments

x

The empirical distribution object.

g

The function to apply to each observation.

...

Additional arguments to pass into function g.

Examples

Run this code
ed <- empirical_dist(c(1, 2, 3, 4))
ed2 <- rmap(ed, function(x) x^2)
mean(ed2) # mean of 1, 4, 9, 16

Run the code above in your browser using DataLab