pow | R Documentation |
This function returns a numeric vector raised to a given power.
pow(x, y)
x |
A numeric vector. |
y |
A numeric value for the power |
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.
a numeric vector containing x
to the power of y
.
Sollano Rabelo Braga sollanorb@gmail.com
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) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.