Learn R Programming

FSM (version 1.0.0)

make_sq_inter: Squares and two-way interactions of variables

Description

Generates squares and/or two-way interactions (pairwise products) of the columns of a data frame.

Usage

make_sq_inter(
  data_frame,
  is_square = TRUE,
  is_inter = TRUE,
  keep_marginal = TRUE
)

Arguments

data_frame

Data frame containing the variables whose squares and interactions are to be created.

is_square

If TRUE, square of each column of data_frame is created.

is_inter

If TRUE, product of every pair of columns of data_frame is created.

keep_marginal

If TRUE, the original columns of data_frame are retained in the resulting data frame.

Value

A data frame containing the squares and/or pairwise products of data_frame.

Examples

Run this code
# NOT RUN {
# Consider a data frame with N = 12 units and 2 covariates.
data_frame_sample = data.frame(male = c(rep(1,6),rep(0,6)), 
age = c(20,30,40,40,50,60,20,30,40,40,50,60))
# Get a data frame with all possible squares and first order interactions.
make_sq_inter(data_frame = data_frame_sample, is_square = TRUE, 
is_inter = TRUE, keep_marginal = FALSE)
# }

Run the code above in your browser using DataLab