expand: Expand Data by Weight

Description Usage Arguments Value Examples

View source: R/expand.R

Description

Expand Data by Weight

Usage

1
expand(x, weight)

Arguments

x

dataframe or matrix

weight

weight column names or index

Value

expanded data

Examples

1
2
3
4
5
df=data.frame(v=c(1,2,3),
               x=c(7,8,9),
               n=c(2,3,4))
expand(x = df,weight = 3)
expand(x = df,weight = 'n')

Example output

  v x n
1 1 7 2
2 1 7 2
3 2 8 3
4 2 8 3
5 2 8 3
6 3 9 4
7 3 9 4
8 3 9 4
9 3 9 4
  v x n
1 1 7 2
2 1 7 2
3 2 8 3
4 2 8 3
5 2 8 3
6 3 9 4
7 3 9 4
8 3 9 4
9 3 9 4

do documentation built on Aug. 3, 2021, 5:06 p.m.