cols.rep: Replicate Columns in a Data Frame

View source: R/aided_chatgpt.R

cols.repR Documentation

Replicate Columns in a Data Frame

Description

This function replicates each column in a data frame a specified number of times.

Usage

cols.rep(data, n)

Arguments

data

A data frame whose columns are to be replicated.

n

An integer specifying the number of times each column should be replicated.

Value

A data frame with each column replicated 'n' times. If 'n' is less than or equal to 0, an empty data frame is returned.

Examples

# Example with a simple data frame
df <- data.frame(A = c(1, 2), B = c(3, 4))
cols.rep(df, 3)

# Example with no replication (n = 0)
cols.rep(df, 0)


quickcode documentation built on April 11, 2025, 5:49 p.m.