Learn R Programming

TDMR (version 2.2)

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

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

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.