Learn R Programming

wildcard (version 1.0.3)

expandrows: Function expand

Description

Expand the rows of a data frame Copied and modified from remakeGenerator::expand() under GPL>=3: https://github.com/wlandau/remakeGenerator

Usage

expandrows(df, n = 2, type = c("each", "times"))

Arguments

df

data frame

n

number of duplicates per row

type

character scalar. If 'each', rows will be duplicated in place. If 'times', the data frame itself will be repeated n times

See Also

wildcard]

Examples

Run this code
# NOT RUN {
df <- data.frame(
  ID = c('24601', 'Javert', 'Fantine'), 
  fate = c('fulfillment', 'confusion', 'misfortune'))
expandrows(df, n = 2, type = 'each')
expandrows(df, n = 2, type = 'times')
# }

Run the code above in your browser using DataLab