tdmPreAddMonomials: Add monomials of degree 2 to a data frame.

Description Usage Arguments Value Note

View source: R/tdmPreprocUtils.r

Description

Given the data frame dset and a data frame rx with the same number of rows, add monomials of degree 2 to dset for all quadratic combinations of the first PRE.npc columns of rx. The naming of these new columns is "R1x2" for the combination of cols 1 and 2 and so on (if prefix="R").

Usage

1
tdmPreAddMonomials(dset, rx, PRE.npc, opts, degree = 2, prefix = "R")

Arguments

dset

the target data frame

rx

a data frame where to draw the monomials from

PRE.npc

the number of columns from rx to use (clipped to ncol(rx) if necessary)

opts

a list from which we need here the following entries:

  • filename

  • VERBOSE

degree

[2] (currently only 2 is supported)

prefix

["R"] character prefix for the monomial column names

Value

data frame dset with the new monomial columns appended. If PRE.npc==0, the data frame is returned unchanged.

Note

CAVEAT: The double for-loop costs some time (e.g. 2-4 sec for ncol(rx)=8 or 10) How to fix: make a version w/o for-loop and w/o frequent assigns to dset (**TODO**)


TDMR documentation built on March 3, 2020, 1:06 a.m.