Learn R Programming

intubate (version 1.0.0)

lars: Interfaces for lars package for data science pipelines.

Description

Interfaces to lars functions that can be used in a pipeline implemented by magrittr.

Usage

ntbt_lars(data, ...) ntbt_cv.lars(data, ...)

Arguments

data
data frame, tibble, list, ...
...
Other arguments passed to the corresponding interfaced function.

Value

Object returned by interfaced function.

Details

Interfaces call their corresponding interfaced function.

Examples

Run this code
## Not run: 
# library(intubate)
# library(magrittr)
# library(lars)
# 
# 
# library(ISLR)
# data("Hitters")
# Hitters <- na.omit(Hitters)
# 
# dta <- list(x = model.matrix(Salary ~ ., Hitters)[, -1],  ## Remove intercept
#             y = model.frame(Salary ~ ., Hitters)[, 1])
# 
# ## ntbt_lars: Fits Least Angle Regression, Lasso and Infinitesimal
# ##            Forward Stagewise regression models
# 
# ## Original function to interface
# attach(dta)
# lasso <- lars(x, y)
# plot(lasso)
# detach()
# 
# ## The interface puts data as first parameter
# lasso <- ntbt_lars(dta, x, y)
# plot(lasso)
# 
# ## so it can be used easily in a pipeline.
# dta %>%
#   ntbt_lars(x, y) %>%
#   plot()
# 
# 
# ## ntbt_cv.lars: Computes K-fold cross-validated error curve for lars
# 
# ## Original function to interface
# set.seed(1)
# attach(dta)
# cv.lars(x, y)
# detach()
# 
# ## The interface puts data as first parameter
# set.seed(1)
# ntbt_cv.lars(dta, x, y)
# 
# ## so it can be used easily in a pipeline.
# set.seed(1)
# dta %>%
#   ntbt_cv.lars(x, y)
# ## End(Not run)

Run the code above in your browser using DataLab