Learn R Programming

linear.tools (version 1.3.0)

get_y: get y (right hand of var)

Description

get y (right hand of var)

Usage

get_y(Formula, method = c("raw", "model", "coeff"))

Arguments

Formula
a formula to be paste.
method
either 'raw','model', or 'coeff', to decide what kind variables to show. Default is 'raw'. See section Detials below.

Value

y in formula

Details

What do 'raw' variable, 'model' variable, and 'coeff' variable mean?

  • raw var is the underlying variable without any calculation or transformation.
  • model var is the underlying variable with calculations or transformation.
  • coeff var is the coefficient variable in the model output. So only evaluated model has coeff var.

In the formula, log(y) ~ x1 + x2, we have: 'raw' variable for y: y 'model' variable for y: log(y) 'coeff' variable for y: log(y)

More examples see the sample code below.

Examples

Run this code

get_y(log(price) ~sdfsf + dsa )
get_y(log(price) ~ sdfsf + dsa, method = "model")
get_y(log(price) ~ sdfsf + dsa, method = "coeff") # same as model var in the get_y() case

# can deal with un-regular formula
get_y(log(price) ~sdfsf + dsa ~ dsad)
get_y(log(price) ~ sdfsf + dsa ~ dsad, method = "coeff")
get_y(log(price) ~ sdfsf + dsa ~ dsad, method = "model")

model_dirty = model = lm(price~  I(carat^   2) + cut  - carat:table - cut ,ggplot2::diamonds)
get_y(model_dirty)

Run the code above in your browser using DataLab