Learn R Programming

rineq (version 0.3.0)

plot.decomposition: Plots a barplot of the contribution percentages in a decomposition object. Sets custom plot margins and uses the graphical parameters xlim, horiz, las and xlab which therefore cannot be customized

Description

Plots a barplot of the contribution percentages in a decomposition object. Sets custom plot margins and uses the graphical parameters xlim, horiz, las and xlab which therefore cannot be customized

Usage

# S3 method for decomposition
plot(x, decreasing = TRUE, horiz = FALSE, ...)

Value

Invisibly returns x as the function is called for side effects (plotting).

Arguments

x

Object returned from decomposition function

decreasing

Whether to sort contributions decreasing or not

horiz

If the barplots should be printed horizontally or vertically

...

Graphical parameter passed on to base::barplot()

Examples

Run this code
data(housing)
# Linear regression & decompose 
fit.lm <- lm(bmi ~ sex + tenure + place + age,data = housing)
contrib.lm <- contribution(fit.lm, housing$income)

# plot horizontally, in increasing order
plot(contrib.lm, decreasing = FALSE, horiz = TRUE)

Run the code above in your browser using DataLab