Description Usage Arguments Details Author(s) See Also Examples
"DDF" recombination - results into a "ddf" object, rbinding if necessary
1 |
... |
additional attributes to define the combiner (currently only used internally) |
combDdf
is passed to the argument combine
in recombine
.
If the value
of the "ddo" object that will be recombined is a list, then the elements in the list will be
collapsed together via rbind
.
Ryan Hafen
divide
, recombine
, combCollect
, combMeanCoef
, combRbind
, combDdo
, combDdf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # Divide the iris data
bySpecies <- divide(iris, by = "Species")
## Simple combination to form a ddf
##---------------------------------------------------------
# Add a transform that selects the petal width and length variables
selVars <- function(x) x[,c("Petal.Width", "Petal.Length")]
# Apply the transform and combine using combDdo
combined <- recombine(addTransform(bySpecies, selVars), combine = combDdf)
combined
combined[[1]]
# A more concise (and readable) way to do it
bySpecies %>%
addTransform(selVars) %>%
recombine(combDdf)
## Combination that involves rbinding to give the ddf
##---------------------------------------------------------
# A transformation that returns a list
listTrans <- function(x) {
list(meanPetalWidth = mean(x$Petal.Width),
maxPetalLength = max(x$Petal.Length))
}
# Apply the transformation and look at the result
bySpeciesTran <- addTransform(bySpecies, listTrans)
bySpeciesTran[[1]]
# And if we rbind the "value" of the first subset:
out1 <- rbind(bySpeciesTran[[1]]$value)
out1
# Note how the combDdf method row binds the two data frames
combined <- recombine(bySpeciesTran, combine = combDdf)
out2 <- combined[[1]]
out2
# These are equivalent
identical(out1, out2$value)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.