Learn R Programming

Kmisc (version 0.5.0)

kCoef: Nicely Formatted Model Coefficient Output

Description

A customized coefficient function that assigns better row names to the coefficient matrix returned by coef() for a model fit. Also includes some arguments for parsing of variable names.

Usage

kCoef(fit, remove_underscore = TRUE, remove_dollar = TRUE, swap_periods = TRUE)

Arguments

fit
the model fit we wish to generate coefficients from.
remove_underscore
remove underscores (and all elements after) in a variable?
remove_dollar
remove all elements before and including a $ in a variable name?
swap_periods
swap periods with spaces?

Value

a matrix of coefficients with nicely formatted names.

Details

NOTE:

Models with interaction effects are currently not handled.

Examples

Run this code
## How the remove_underscore and remove_dollar arguments act:
## An example:
##                     kDat$variable_other_stuff
## remove_underscore:  +++++++++++++------------
## remove_dollar:      -----++++++++++++++++++++

x <- rnorm(100); y <- x * runif(100)
z <- as.factor( rep( c("apple", "banana", "cherry", "date"), each=25 ) )
myFit <- lm( y ~ x + z )

## compare the output of these two: which do you prefer?
coef( summary( myFit ) )
kCoef( myFit )

Run the code above in your browser using DataLab