InsertRow: Inserts a new row into a data frame

Description Usage Arguments Source Examples

View source: R/utils.R

Description

Inserts a new row into a data frame

Usage

1
InsertRow(data, NewRow, RowNum = NULL)

Arguments

data

a data frame to insert the new row into.

NewRow

a vector whose length is the same as the number of columns in data.

RowNum

numeric indicating which row to insert the new row as. If not specified then the new row is added to the end using a vanilla rbind call.

Source

The function largely implements: http://stackoverflow.com/a/11562428

Examples

1
2
3
4
5
6
7
8
9
# Create dummy data
A <- B <- C <- D <- sample(1:20, size = 20, replace = TRUE)
Data <- data.frame(A, B, C, D)

# Create new row
New <- rep(1000, 4)

# Insert into 4th row
Data <- InsertRow(Data, NewRow = New, RowNum = 4)

DataCombine documentation built on May 30, 2017, 2:52 a.m.