groups: Quantifying the influence of a factor variable

Description Usage Arguments Value Author(s) See Also Examples

View source: R/groups.R

Description

The function calculates a linear model by calling lm(xi~classvar) for all numeric variables (xi) from x and returns the coefficients of determination. The aim is to find numeric variables for which high ratios of the variability can be explained by a factor variable classvar.

Usage

1
groups(data, classvar)

Arguments

data

A data frame.

classvar

A factor. The variable which is used to explain the numeric variables from x.

Value

If x is a numeric vector, the coefficient of determination of the model described by lm(x~classvar) is returned. Otherwise a data frame with the following two variables:

groups

coefficient of determination.

variable

actual variable.

Author(s)

Katrin Grimm

See Also

groups_maxplot, lm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(Election2005)
## Not run: 
# Define new variable which explains affiliation of the constituencies
# to east Germany, west Germany and Berlin 
OstWest <-  ifelse(Election2005$Land %in% 
    c("Thueringen","Sachsen","Sachsen-Anhalt",
    "Brandenburg","Mecklenburg-Vorpommern"),  "Ost", "West")
Election2005$OstWestBerlin <- 
  as.factor(ifelse(Election2005$Land == "Berlin","Berlin",OstWest))

# Calculate measure groups 
groupm <- groups(Election2005, "OstWestBerlin")
# Show highest values 
groupm[with(groupm,order(groups,decreasing=TRUE))[1:10],]

## End(Not run)

mbgraphic documentation built on May 2, 2019, 2:45 a.m.