I want to end a pipe with an assignment operator in R.
my goal (in pseudo R):
data %>% analysis functions %>% analyzedData
where data and analyzedData are both a data.frame.
I've tried a few variants of this, each giving a unique error message. some iterations I've tried:
data %>% analysis functions %>% -> analyzedData
data %>% analysis functions %>% .-> analyzedData
data %>% analysis functions %>% <-. analyzedData
data %>% analysis functions %>% <- analyzedData
Error messages:
Error in function_list[[k]](value) :
could not find function "analyzedData"
Error: object 'analyzedData' not found
Error: unexpected assignment in: ..
Update: the way I figured out to do this is:
data %>% do analysis %>% {.} -> analyzedData
This way, to troubleshoot / debug a long pipe, you can drop these two line into your pipe to minimize code rerun and to isolate the problem.
data %>% pipeline functions %>%
{.}-> tempWayPoint
tmpWayPoint %>%
more pipeline functions %>% {.} -> endPipe
analyzedData <- data %>% analysis functions[<- (). (I can't get the backticks right;[<-is in backticks). The first argument is the object to subset and then assign (so that gets piped in), the next arguments are the subsets of the dimensions of that object (one for each), and the last is the object to assign to that subset, or overwrite it with.