Title: | Split and Recombine Your Data |
---|---|
Description: | Sometimes you need to split your data and work on the two chunks independently before bringing them back together. 'Taber' allows you to do that with its two functions. |
Authors: | Seth Wenchel [aut, cre, cph] |
Maintainer: | Seth Wenchel <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 0.1.2 |
Built: | 2024-10-25 02:59:31 UTC |
Source: | https://github.com/restonslacker/taber |
Remove all objects from the stack by deleting them from memory.
clear_stack()
clear_stack()
library(dplyr) aframe <- data.frame(zed = runif(100)) set_to_zero <- . %>% mutate(zed = 0) aframe %>% scion(zed >0.5, false_fun=set_to_zero) clear_stack()
library(dplyr) aframe <- data.frame(zed = runif(100)) set_to_zero <- . %>% mutate(zed = 0) aframe %>% scion(zed >0.5, false_fun=set_to_zero) clear_stack()
Graft one dataset onto another
graft(.data, combine_fun, data2)
graft(.data, combine_fun, data2)
.data |
A tbl or something that can be coerced into one |
combine_fun |
optional, A function that will combine two tbls such as full_join or bind_rows |
data2 |
A tbl or something that can be coerced into one |
Graft requires two data objects. The first must be provided by the user. The second can either be passed in or automatically pulled off of the package's internal stack of scions. These will be combined accoring to the following rules in order:
If either dataset has zero rows, the other dataset will be returned.
If combine_fun is specifed, combine_fun(.data, data2)
will be called
If all column names match, a row bind will occur
If at least some column names match, a full join will occur
If both have the same number of rows a column bind will be performed
A single tbl object
Seth Wenchel
library(dplyr) aframe <- data.frame(zed = runif(100)) set_to_zero <- . %>% mutate(zed = 0) aframe %>% scion(zed >0.5, false_fun=set_to_zero) %>% mutate(zed=1) %>% graft
library(dplyr) aframe <- data.frame(zed = runif(100)) set_to_zero <- . %>% mutate(zed = 0) aframe %>% scion(zed >0.5, false_fun=set_to_zero) %>% mutate(zed=1) %>% graft
scion
scion(.data, ..., false_fun, false_name, false_env)
scion(.data, ..., false_fun, false_name, false_env)
.data |
A tbl or something that can be coerced into one |
... |
conditions that will be passed to dplyr::filter |
false_fun |
A function or functional that will be applied to the data that doesn't pass the supplied filters (the scion) |
false_name |
optional, the name of the object to which the scion will be assigned. |
false_env |
optional, the environment into which the scion will be assigned. If specified, false_name must also be specified. If unspecified (default), scions will be placed into the internal package environment. |
.data
will be split into two chunks based on the conditions. The scion will be passed through false_fun
and then either placed on
the package's internal stack or assigned as specified by false_name
and false_env
.
A tbl whose rows have passed the stated conditions
Seth Wenchel
library(dplyr) aframe <- data.frame(zed = runif(100)) set_to_zero <- . %>% mutate(zed = 0) aframe %>% scion(zed >0.5, false_fun=set_to_zero) %>% mutate(zed=1) %>% graft
library(dplyr) aframe <- data.frame(zed = runif(100)) set_to_zero <- . %>% mutate(zed = 0) aframe %>% scion(zed >0.5, false_fun=set_to_zero) %>% mutate(zed=1) %>% graft
This is primarily to help with debugging.
stack_view(x)
stack_view(x)
x |
optional string. If supplied it should match the name of an object in the package enviroment. The value of the corresponding variable will be returned. If missing, a list of all objects in the package enviroment. |
Note that graft
does not delete objects from the environment.