aa <- CharacterList("a", paste0("d", 1:2), paste0("b", 1:3), c(), "c")
bb <- CharacterList(paste0("sna", 1:2),"foo", paste0("bar",1:3),c(),"hica")
df <- DataFrame(aa=aa, bb=bb, cc=11:15)
## expand by all list-like columns (aa, bb), dropping empty rows
expand(df)
## expand the aa column only, and keep rows adjacent to empty values
expand(df, colnames="aa", keepEmptyRows=TRUE)
## expand the aa column only but do not keep rows
expand(df, colnames="aa", keepEmptyRows=FALSE)
## expand the aa and then the bb column, but
## keeping rows next to empty compressed values
expand(df, colnames=c("aa","bb"), keepEmptyRows=TRUE)
## expand the bb and then the aa column, but don't keep rows adjacent to
## empty values from bb and aa
expand(df, colnames=c("aa","bb"), keepEmptyRows=FALSE)
Run the code above in your browser using DataLab