insertRows: Inserts a matrix into another matrix.

Description Usage Arguments Examples

Description

Inserts a matrix or data frame into another matrix or data frame. The new rows are placed together at the row index specified.

Usage

1
insertRows(existing, insert, r)

Arguments

existing

table to insert into

insert

rows to insert

r

index at which to insert

Examples

1
2
3
4
5
6
7
df1<-data.frame(a=c(1,2,3),b=c(1,2,3),c=c(1,2,3))
insertRows(df1,data.frame(list('a','a','a')),5)
insertRows(df1,data.frame(list('a','a','a')),4)
insertRows(df1,data.frame(list('a','a','a')),3)
insertRows(df1,data.frame(list('a','a','a')),2)
insertRows(df1,data.frame(list('a','a','a')),1)
insertRows(df1,df1,3)

Example output

  a b c
1 1 1 1
2 2 2 2
3 3 3 3
4 a a a
  a b c
1 1 1 1
2 2 2 2
3 3 3 3
4 a a a
  a b c
1 1 1 1
2 2 2 2
4 a a a
3 3 3 3
  a b c
1 1 1 1
4 a a a
2 2 2 2
3 3 3 3
  a b c
4 a a a
1 1 1 1
2 2 2 2
3 3 3 3
  a b c
1 1 1 1
2 2 2 2
4 1 1 1
5 2 2 2
6 3 3 3
3 3 3 3

rowr documentation built on May 1, 2019, 11:29 p.m.

Related to insertRows in rowr...