Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Remove splitting variables from a data frame. | ||
#' | ||
#' This is useful when you want to perform some operation to every column | ||
#' in the data frame, except the variables that you have used to split it. | ||
#' These variables will be automatically added back on to the result when | ||
#' combining all results together. | ||
#' | ||
#' @param df data frame produced by \code{d*ply}. | ||
#' @export | ||
#' @examples | ||
#' dlply(mtcars, c("vs", "am")) | ||
#' dlply(mtcars, c("vs", "am"), strip_splits) | ||
strip_splits <- function(df) { | ||
x[setdiff(names(df), attr(df, "vars"))] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
\name{strip_splits} | ||
\alias{strip_splits} | ||
\title{Remove splitting variables from a data frame.} | ||
\usage{strip_splits(df)} | ||
|
||
\description{ | ||
Remove splitting variables from a data frame. | ||
} | ||
|
||
\details{ | ||
This is useful when you want to perform some operation to | ||
every column in the data frame, except the variables that | ||
you have used to split it. These variables will be | ||
automatically added back on to the result when combining | ||
all results together. | ||
} | ||
\arguments{ | ||
\item{df}{data frame produced by \code{d*ply}.} | ||
} | ||
\examples{dlply(mtcars, c("vs", "am")) | ||
dlply(mtcars, c("vs", "am"), strip_splits)} |