pwr: Take the an arbitrary power and plot it.

Description Usage Arguments Details Value See Also Examples

Description

This function takes the a number or vector of numbers, and plots the resultant function if indicated.

Usage

1
pwr(x, a, plot_it = FALSE, returnVal = TRUE, returnPlot = FALSE)

Arguments

x

The vector to be operated on.

a

A numeric that x will be exponentiated to.

plot_it

A logical switch. If TRUE then a quick plot of the power function is created.

returnVal

A logical switch. If TRUE then the a vector of inverted inputs is returned. TRUE by default, but useful if you only wish to plot the input.

returnPlot

A logical switch. If TRUE then the function plot is returned as part of the output object.

Details

The function output depends on what inputs are used. In the case of numeric or logical data, the output will simply be the input taken to the a-th power.

In the case of characters, the output will generally be the input repeated |a| times. If |a| is negative, then the order of the characters is also reverse. If |a| is 0, the output is only the first letter of the input string. In addition, for character inputs the plot_it switch does not have any effect.

By selecting returnPlot = TRUE then the output will contain a plot object. In the case of character vectors, no plot is generated and the plot object is empty.

Value

A vector that is the a-th power of x, this output can be supressed with returnVal. Option to also return a plot object with returnPlot.

See Also

square, cube, reciprocal, tenvec, negtenvec

Examples

1
2
3
4
5
6
plot_object <- reciprocal(1:20, plot_it = TRUE, returnVal = FALSE, returnPlot = TRUE)
reciprocal(-5)
reciprocal(-2)
reciprocal(TRUE)
reciprocal(letters)
reciprocal("hello world")

HScheiber/powers documentation built on May 22, 2019, 1 p.m.