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

inv

Calculate the inverse of a number


Description

This function returns the inverse of a numeric vector.

Usage

inv(x)

Arguments

x

A numeric vector

Details

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

Value

a numeric vector containing the inverse of x.

Author(s)

Sollano Rabelo Braga sollanorb@gmail.com

Examples

library(forestmangr)
data("exfm15")
exfm15

# Get the inverse of a vector
inv(iris$Petal.Length)

# Fit a model that contains the inverse of a variable, without the need to
# create a new variable for the inverse:
lm(log(TH) ~ inv(DBH), exfm15 )
# or 
lm_table(exfm15, log(TH) ~ inv(DBH) )

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.