duplicateRow: Duplicates elements of a data frame

View source: R/duplicateRow.R

duplicateRowR Documentation

Duplicates elements of a data frame

Description

Duplicates rows and columns of a given a data frame.

Usage

duplicateRow(x, id.el = 1, times = 1, append = FALSE)

duplicateCol(x, id.el = 1, times = 1, append = FALSE)

Arguments

x

a data frame.

id.el

identity of the elements to be duplicated.

times

number of times elements are duplicated. Could be a vector of the same length as id.el.

append

A logical. If TRUE, duplicated elements will be appended to the data frame otherwise duplicated elements remain next to their parent. Non-existing columns cannot be duplicated while non-existing rows can and produce NA.

Value

returns a data frame with duplicated rows.

Functions

  • duplicateCol(): returns a data frame with duplicated columns.

Examples

data(iris, package = "datasets")
iris2 <- duplicateRow(iris, id.el = 1:50, times = 2)
iris3 <- duplicateCol(
iris,
id.el = c("Petal.Length", "Petal.Width"),
times = c(1, 2),
append = TRUE)


letiR/letiRmisc documentation built on Sept. 11, 2022, 12:43 a.m.