expandDF: Functions to manipulate data frames

Description Usage Arguments Details Value Examples

Description

expandDF takes a dataframe and replicates the chosen observations n times

Usage

1
2
3
4
5
  expandDF(df, obs, numtimes = 1)

  splitDF(df, splitvar)

  unsplitDF(splitdfs)

Arguments

df

Data.frame to be manipulated

obs

Vector to select rows of df (e.g. vector of row numbers or a boolean of length nrow(df) )

numtimes

Number of times to replicate

splitvar

Name of variable which defines groups on which df will be split

splitdfs

List of data.frames to recombine (generally created by splitDF)

Details

splitDF takes a dataframe and splits it into a bunch of data.frames held in a list, according to one variable

unsplitDF takes a list of data.frames produced by splitDF and returns them as one appended data.frame

Value

expandDF and unsplitDF return a data.frame splitDF returns a list of data.frames

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(datasets)
# Duplicate a dataset
expandDF(sleep,TRUE)
# Expand the final observation
expandDF(sleep,nrow(sleep),numtimes=10)
# Split a data.frame by group
s.df <- splitDF(sleep,'group')
s.df
# Reconstitute original data.frame
unsplitDF(s.df)

gsk3/taRifx documentation built on May 17, 2019, 8:55 a.m.