Learn R Programming

datadr (version 0.8.6.1)

drLM: LM Transformation Method

Description

LM transformation method -- -- Fit a linear model to each subset

Usage

drLM(...)

Arguments

arguments you would pass to the lm function

Value

An object of class drCoef that contains the lm coefficients and other data needed by combMeanCoef

Details

This provides a transformation function to be called for each subset in a recombination MapReduce job that applies R's lm method and outputs the coefficients in a way that combMeanCoef knows how to deal with. It can be applied to a ddf with addTransform prior to calling recombine.

See Also

divide, recombine, rrDiv

Examples

Run this code
# NOT RUN {
# Divide the data
bySpecies <- divide(iris, by = "Species")

# A function to fit a multiple linear regression model to each species
linearReg <- function(x)
  drLM(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width,
       data = x)

# Apply the transform and combine using 'combMeanCoef'
bySpecies %>%
  addTransform(linearReg) %>%
  recombine(combMeanCoef)

# }

Run the code above in your browser using DataLab