Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pow

Raise a numeric vector to a given power


Description

This function returns a numeric vector raised to a given power.

Usage

pow(x, y)

Arguments

x

A numeric vector.

y

A numeric value for the power x should be raised to.

Details

This function is manly used when fitting statistical models. If one of the variables in a model is a variable raised to a given power, the lm function does not properly compute the variable, if vector^power is inserted directly in the model, leading to the need of creating a separate variable. This function allows the user to get the power of a given numeric vector to y inside the model, without the need to create a new variable.

Value

a numeric vector containing x to the power of y.

Author(s)

Sollano Rabelo Braga sollanorb@gmail.com

Examples

library(forestmangr)
data("exfm15")
head(exfm15)

# Raise a numeric vector to the power of 2:
pow(iris$Petal.Length, 2)

# Fit a model that contains the dbh squared, without the need to create a new variable:
lm(log(TH) ~ DBH + pow(DBH,2), exfm15 )
# or 
lm_table(exfm15, log(TH) ~ DBH + pow(DBH,2) )

forestmangr

Forest Mensuration and Management

v0.9.3
MIT + file LICENSE
Authors
Sollano Rabelo Braga [aut, cre, cph], Marcio Leles Romarco de Oliveira [aut], Eric Bastos Gorgens [aut]
Initial release
2021-01-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.