Skip to content

Commit

Permalink
Merge pull request #15 from joachim-gassen/master
Browse files Browse the repository at this point in the history
Attempt at a fix of issue #14
  • Loading branch information
daranzolin committed Oct 1, 2019
2 parents 7377b65 + bca43f2 commit 0772271
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/viewPipeChain.R
Expand Up @@ -49,9 +49,14 @@ processPipeChain <- function(cmd) {
collapse = " ")))
assign(sprintf("ps%d", i), eval(call))
}
assign(sprintf("obj%d", i), ifelse(is.data.frame(get(sprintf("ps%d", i))),
as.data.frame(get(sprintf("ps%d", i))),
get(sprintf("ps%d", i))))
assign(
sprintf("obj%d", i),
if (is.data.frame(get(sprintf("ps%d", i)))) {
as.data.frame(get(sprintf("ps%d", i)))
} else {
get(sprintf("ps%d", i))
}
)
if (i == 1 || !identical(get(sprintf("obj%d", i)),
get(sprintf("obj%d", i- 1))))
eval(parse(text = sprintf(cmd, i)))
Expand Down
8 changes: 8 additions & 0 deletions tools/test_cases.R
Expand Up @@ -50,6 +50,14 @@ iris %>%
Petal.Length.min = min(Petal.Length),
Petal.Width.min = min(Petal.Width)) -> min_iris

# Example from issue #14

diamonds %>%
select(carat, cut, color, clarity, price) %>%
group_by(color) %>%
summarise(n = n(), price = mean(price)) %>%
arrange(desc(color))

# Assign with pipe (esoteric, works)
assign("result", mtcars %>% filter(am == 1) %>% select(qsec))

Expand Down

0 comments on commit 0772271

Please sign in to comment.