Square, cube, or take the reciprocal/inverse of a vector OR a list of numbers.

cube(x)

reciprocal(x)

square(x)

Arguments

x

Vector or list of numbers.

Value

A vector (atomic, double) that is the:

  • square (for square)

  • cube (for cube)

  • reciprocal/inverse (for reciprocal)

of x.

Examples

cube(tenvec)
#> [1] 1 8 27 64 125 216 343 512 729 1000
square(-5)
#> [1] 25
reciprocal(2)
#> [1] 0.5
square(list(1, 4, 5))
#> [1] 1 16 25