| @@ -10,4 +10,3 @@ export(animate_semi_join) | |||
| export(animate_setdiff) | |||
| export(animate_union) | |||
| export(animate_union_all) | |||
| export(combine) | |||
| @@ -7,6 +7,8 @@ | |||
| #' @param export if the function exports a gif, the first, or last picture | |||
| #' @param ... further arguments passed to base_plot | |||
| #' | |||
| #' | |||
| #' @name animate_set_function | |||
| #' @return either a gif or a ggplot | |||
| #' | |||
| #' @examples | |||
| @@ -30,13 +32,14 @@ animate_set <- function(x, y, type, export = "gif", ...) { | |||
| step0 <- bind_rows(ll$x, ll$y) %>% mutate(.frame = 0, .alpha = 1) | |||
| step1 <- tidyAnimatedVerbs:::combine(ll$x, ll$y, type) %>% mutate(.frame = 1) | |||
| step1 <- move_together(ll$x, ll$y, type) %>% mutate(.frame = 1) | |||
| all <- bind_rows(step0, step1) | |||
| if (export == "gif") { | |||
| animate_plot(all, title, ...) %>% animate() | |||
| } else if (export == "first") { | |||
| title <- "" | |||
| base_plot(step0, title, ...) | |||
| } else if (export == "last") { | |||
| base_plot(step1, title, ...) | |||
| @@ -54,6 +57,7 @@ animate_set <- function(x, y, type, export = "gif", ...) { | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' | |||
| #' @name animate_join_function | |||
| #' @examples | |||
| #' NULL | |||
| animate_join <- function(x, y, by, type, export = "gif", ...) { | |||
| @@ -74,14 +78,14 @@ animate_join <- function(x, y, by, type, export = "gif", ...) { | |||
| step0 <- bind_rows(ll$x, ll$y) %>% mutate(.frame = 0, .alpha = 1) | |||
| step1 <- tidyAnimatedVerbs:::combine(ll$x, ll$y, type) %>% mutate(.frame = 1) | |||
| step1 <- move_together(ll$x, ll$y, type) %>% mutate(.frame = 1) | |||
| all <- bind_rows(step0, step1) | |||
| if (export == "gif") { | |||
| animate_plot(all, title, ...) %>% animate() | |||
| } else if (export == "first") { | |||
| title <- "" | |||
| base_plot(step0, title, ...) | |||
| } else if (export == "last") { | |||
| base_plot(step1, title, ...) | |||
| @@ -1,5 +1,7 @@ | |||
| #' Animates a full join | |||
| #' Animates a join operations | |||
| #' | |||
| #' Functions to visualise the join operations either static as a ggplot, or | |||
| #' dynamic as a gif. | |||
| #' | |||
| #' @param x the x dataset | |||
| #' @param y the y dataset | |||
| @@ -9,8 +11,10 @@ | |||
| #' @param ... further arguments passed to base_plot | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @export | |||
| #' | |||
| #' @seealso \code{\link[dplyr]{join}} | |||
| #' | |||
| #' @name animate_join | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| @@ -21,195 +25,69 @@ | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' # Animate the first or last state of the join | |||
| #' animate_full_join(x, y, by = "id", export = "first") | |||
| #' animate_full_join(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # animate the transition as a gif (default) | |||
| #' \donttest{ | |||
| #' animate_full_join(x, y, by = "id", export = "gif") | |||
| #' } | |||
| #' | |||
| #' # different options include | |||
| #' \donttest{ | |||
| #' animate_full_join(x, y, by = "id") | |||
| #' animate_inner_join(x, y, by = "id") | |||
| #' animate_left_join(x, y, by = "id") | |||
| #' animate_right_join(x, y, by = "id") | |||
| #' animate_semi_join(x, y, by = "id") | |||
| #' animate_anti_join(x, y, by = "id")#' | |||
| #' } | |||
| #' | |||
| #' # Save the results | |||
| #' \donttest{ | |||
| #' # to save the ggplot, use | |||
| #' fj <- animate_full_join(x, y, by = "id", export = "last") | |||
| #' ggsave("full-join.pdf", fj) | |||
| #' | |||
| #' animate_full_join(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' fj <- animate_full_join(x, y, by = "id", export = "gif") | |||
| #' anim_save(fj, "full-join.gif") | |||
| #' } | |||
| #' | |||
| NULL | |||
| #' @rdname animate_join | |||
| #' @export | |||
| animate_full_join <- function(x, y, by, export = "gif", ...) { | |||
| animate_join(x, y, by, type = "full_join", export = export, ...) | |||
| } | |||
| #' Animates an inner join | |||
| #' | |||
| #' @inheritParams animate_full_join | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_join | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_inner_join(x, y, by = "id", export = "first") | |||
| #' animate_inner_join(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' ij <- animate_inner_join(x, y, by = "id", export = "last") | |||
| #' ggsave("inner-join.pdf", ij) | |||
| #' | |||
| #' animate_inner_join(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' ij <- animate_inner_join(x, y, by = "id", export = "gif") | |||
| #' anim_save(ij, "inner-join.gif") | |||
| #' } | |||
| #' | |||
| animate_inner_join <- function(x, y, by, export = "gif", ...) { | |||
| animate_join(x, y, by, type = "inner_join", export = export, ...) | |||
| } | |||
| #' Animates a left join | |||
| #' | |||
| #' @inheritParams animate_full_join | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_join | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_left_join(x, y, by = "id", export = "first") | |||
| #' animate_left_join(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' lj <- animate_left_join(x, y, by = "id", export = "last") | |||
| #' ggsave("left-join.pdf", lj) | |||
| #' | |||
| #' animate_left_join(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' lj <- animate_left_join(x, y, by = "id", export = "gif") | |||
| #' anim_save(lj, "left-join.gif") | |||
| #' } | |||
| #' | |||
| animate_left_join <- function(x, y, by, export = "gif", ...) { | |||
| animate_join(x, y, by, type = "left_join", export = export, ...) | |||
| } | |||
| #' Animates a right join | |||
| #' | |||
| #' @inheritParams animate_full_join | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_join | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_right_join(x, y, by = "id", export = "first") | |||
| #' animate_right_join(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' rj <- animate_right_join(x, y, by = "id", export = "last") | |||
| #' ggsave("right-join.pdf", rj) | |||
| #' | |||
| #' animate_right_join(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' rj <- animate_right_join(x, y, by = "id", export = "gif") | |||
| #' anim_save(rj, "right-join.gif") | |||
| #' } | |||
| #' | |||
| animate_right_join <- function(x, y, by, export = "gif", ...) { | |||
| animate_join(x, y, by, type = "right_join", export = export, ...) | |||
| } | |||
| #' Animates a semi join | |||
| #' | |||
| #' @inheritParams animate_full_join | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_join | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_semi_join(x, y, by = "id", export = "first") | |||
| #' animate_semi_join(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' sj <- animate_semi_join(x, y, by = "id", export = "last") | |||
| #' ggsave("semi-join.pdf", sj) | |||
| #' | |||
| #' animate_semi_join(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' sj <- animate_semi_join(x, y, by = "id", export = "gif") | |||
| #' anim_save(sj, "semi-join.gif") | |||
| #' } | |||
| #' | |||
| animate_semi_join <- function(x, y, by, export = "gif", ...) { | |||
| animate_join(x, y, by, type = "semi_join", export = export, ...) | |||
| } | |||
| #' Animates an anti join | |||
| #' | |||
| #' @inheritParams animate_full_join | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_join | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_anti_join(x, y, by = "id", export = "first") | |||
| #' animate_anti_join(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' aj <- animate_anti_join(x, y, by = "id", export = "last") | |||
| #' ggsave("anti-join.pdf", aj) | |||
| #' | |||
| #' animate_anti_join(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' aj <- animate_anti_join(x, y, by = "id", export = "gif") | |||
| #' anim_save(aj, "anti-join.gif") | |||
| #' } | |||
| #' | |||
| animate_anti_join <- function(x, y, by, export = "gif", ...) { | |||
| animate_join(x, y, by, type = "anti_join", export = export, ...) | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| #' Animates a union set | |||
| #' Animates a set operation | |||
| #' | |||
| #' Functions to visualise the set operations either static as a ggplot, or | |||
| #' dynamic as a gif. | |||
| #' | |||
| #' @param x the x dataset | |||
| #' @param y the y dataset | |||
| @@ -8,8 +10,10 @@ | |||
| #' @param ... further argument passed to base_plot | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @export | |||
| #' | |||
| #' @seealso \code{\link[dplyr]{setops}} | |||
| #' | |||
| #' @name animate_set | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| @@ -23,6 +27,24 @@ | |||
| #' animate_union(x, y, by = "id", export = "first") | |||
| #' animate_union(x, y, by = "id", export = "last") | |||
| #' | |||
| #' # Animate the first or last state of the join | |||
| #' animate_union(x, y, export = "first") | |||
| #' animate_union(x, y, export = "last") | |||
| #' | |||
| #' # animate the transition as a gif (default) | |||
| #' \donttest{ | |||
| #' animate_union(x, y, export = "gif") | |||
| #' } | |||
| #' | |||
| #' # different options include | |||
| #' \donttest{ | |||
| #' animate_union(x, y, by = "id") | |||
| #' animate_union_all(x, y, by = "id") | |||
| #' animate_intersect(x, y, by = "id") | |||
| #' animate_setdiff(x, y, by = "id") | |||
| #' } | |||
| #' | |||
| #' # Save the results | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' un <- animate_union(x, y, by = "id", export = "last") | |||
| @@ -33,112 +55,28 @@ | |||
| #' un <- animate_union(x, y, by = "id", export = "gif") | |||
| #' anim_save(un, "union.gif") | |||
| #' } | |||
| #' | |||
| NULL | |||
| #' @rdname animate_set | |||
| #' @export | |||
| animate_union <- function(x, y, export = "gif", ...) { | |||
| animate_set(x, y, type = "union", export = export, ...) | |||
| } | |||
| #' Animates a union-all set | |||
| #' | |||
| #' @inheritParams animate_union | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_set | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_union_all(x, y, by = "id", export = "first") | |||
| #' animate_union_all(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' un <- animate_union_all(x, y, by = "id", export = "last") | |||
| #' ggsave("union-all.pdf", un) | |||
| #' | |||
| #' animate_union_all(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' un <- animate_union_all(x, y, by = "id", export = "gif") | |||
| #' anim_save(un, "union-all.gif") | |||
| #' } | |||
| #' | |||
| animate_union_all <- function(x, y, export = "gif", ...) { | |||
| animate_set(x, y, type = "union_all", export = export, ...) | |||
| } | |||
| #' Animates an intersect set | |||
| #' | |||
| #' @inheritParams animate_union | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_set | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_intersect(x, y, by = "id", export = "first") | |||
| #' animate_intersect(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' ints <- animate_intersect(x, y, by = "id", export = "last") | |||
| #' ggsave("intersect.pdf", ints) | |||
| #' | |||
| #' animate_intersect(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' ints <- animate_union_all(x, y, by = "id", export = "gif") | |||
| #' anim_save(ints, "intersect.gif") | |||
| #' } | |||
| #' | |||
| animate_intersect <- function(x, y, export = "gif", ...) { | |||
| animate_set(x, y, type = "intersect", export = export, ...) | |||
| } | |||
| #' Animates a setdiff set | |||
| #' | |||
| #' @inheritParams animate_union | |||
| #' | |||
| #' @return either a gif or a ggplot | |||
| #' @rdname animate_set | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' x <- data_frame( | |||
| #' id = 1:3, | |||
| #' x = paste0("x", 1:3) | |||
| #' ) | |||
| #' y <- data_frame( | |||
| #' id = (1:4)[-3], | |||
| #' y = paste0("y", (1:4)[-3]) | |||
| #' ) | |||
| #' | |||
| #' animate_setdiff(x, y, by = "id", export = "first") | |||
| #' animate_setdiff(x, y, by = "id", export = "last") | |||
| #' | |||
| #' \dontrun{ | |||
| #' # to save the ggplot, use | |||
| #' setd <- animate_setdiff(x, y, by = "id", export = "last") | |||
| #' ggsave("setdiff.pdf", setd) | |||
| #' | |||
| #' animate_setdiff(x, y, by = "id", export = "gif") | |||
| #' # to save the gif, use | |||
| #' setd <- animate_union_all(x, y, by = "id", export = "gif") | |||
| #' anim_save(setd, "setdiff.gif") | |||
| #' } | |||
| #' | |||
| animate_setdiff <- function(x, y, export = "gif", ...) { | |||
| animate_set(x, y, type = "setdiff", export = export, ...) | |||
| } | |||
| @@ -7,11 +7,10 @@ | |||
| #' joins or sets | |||
| #' | |||
| #' @return processed dataset of the combined values | |||
| #' @export | |||
| #' | |||
| #' @examples | |||
| #' NULL | |||
| combine <- function(lhs, rhs, type) { | |||
| move_together <- function(lhs, rhs, type) { | |||
| all_ids <- bind_rows(lhs, rhs) %>% distinct(.id) | |||
| @@ -1,51 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_anti_join} | |||
| \alias{animate_anti_join} | |||
| \title{Animates an anti join} | |||
| \usage{ | |||
| animate_anti_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates an anti join | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_anti_join(x, y, by = "id", export = "first") | |||
| animate_anti_join(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| aj <- animate_anti_join(x, y, by = "id", export = "last") | |||
| ggsave("anti-join.pdf", aj) | |||
| animate_anti_join(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| aj <- animate_anti_join(x, y, by = "id", export = "gif") | |||
| anim_save(aj, "anti-join.gif") | |||
| } | |||
| } | |||
| @@ -1,51 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_full_join} | |||
| \alias{animate_full_join} | |||
| \title{Animates a full join} | |||
| \usage{ | |||
| animate_full_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a full join | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_full_join(x, y, by = "id", export = "first") | |||
| animate_full_join(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| fj <- animate_full_join(x, y, by = "id", export = "last") | |||
| ggsave("full-join.pdf", fj) | |||
| animate_full_join(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| fj <- animate_full_join(x, y, by = "id", export = "gif") | |||
| anim_save(fj, "full-join.gif") | |||
| } | |||
| } | |||
| @@ -1,51 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_inner_join} | |||
| \alias{animate_inner_join} | |||
| \title{Animates an inner join} | |||
| \usage{ | |||
| animate_inner_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates an inner join | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_inner_join(x, y, by = "id", export = "first") | |||
| animate_inner_join(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| ij <- animate_inner_join(x, y, by = "id", export = "last") | |||
| ggsave("inner-join.pdf", ij) | |||
| animate_inner_join(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| ij <- animate_inner_join(x, y, by = "id", export = "gif") | |||
| anim_save(ij, "inner-join.gif") | |||
| } | |||
| } | |||
| @@ -1,49 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_sets.R | |||
| \name{animate_intersect} | |||
| \alias{animate_intersect} | |||
| \title{Animates an intersect set} | |||
| \usage{ | |||
| animate_intersect(x, y, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further argument passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates an intersect set | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_intersect(x, y, by = "id", export = "first") | |||
| animate_intersect(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| ints <- animate_intersect(x, y, by = "id", export = "last") | |||
| ggsave("intersect.pdf", ints) | |||
| animate_intersect(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| ints <- animate_union_all(x, y, by = "id", export = "gif") | |||
| anim_save(ints, "intersect.gif") | |||
| } | |||
| } | |||
| @@ -1,21 +1,36 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_helpers.R | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_join} | |||
| \alias{animate_join} | |||
| \title{Animates a join - wrapper function} | |||
| \alias{animate_full_join} | |||
| \alias{animate_inner_join} | |||
| \alias{animate_left_join} | |||
| \alias{animate_right_join} | |||
| \alias{animate_semi_join} | |||
| \alias{animate_anti_join} | |||
| \title{Animates a join operations} | |||
| \usage{ | |||
| animate_join(x, y, by, type, export = "gif", ...) | |||
| animate_full_join(x, y, by, export = "gif", ...) | |||
| animate_inner_join(x, y, by, export = "gif", ...) | |||
| animate_left_join(x, y, by, export = "gif", ...) | |||
| animate_right_join(x, y, by, export = "gif", ...) | |||
| animate_semi_join(x, y, by, export = "gif", ...) | |||
| animate_anti_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{left dataset} | |||
| \item{y}{right dataset} | |||
| \item{x}{the x dataset} | |||
| \item{by}{by arguments for the join} | |||
| \item{y}{the y dataset} | |||
| \item{type}{type of the join, i.e., left_join, right_join, etc.} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{if the function exports a gif, the first, or last picture} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| @@ -23,8 +38,49 @@ animate_join(x, y, by, type, export = "gif", ...) | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a join - wrapper function | |||
| Functions to visualise the join operations either static as a ggplot, or | |||
| dynamic as a gif. | |||
| } | |||
| \examples{ | |||
| NULL | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| # Animate the first or last state of the join | |||
| animate_full_join(x, y, by = "id", export = "first") | |||
| animate_full_join(x, y, by = "id", export = "last") | |||
| # animate the transition as a gif (default) | |||
| \donttest{ | |||
| animate_full_join(x, y, by = "id", export = "gif") | |||
| } | |||
| # different options include | |||
| \donttest{ | |||
| animate_full_join(x, y, by = "id") | |||
| animate_inner_join(x, y, by = "id") | |||
| animate_left_join(x, y, by = "id") | |||
| animate_right_join(x, y, by = "id") | |||
| animate_semi_join(x, y, by = "id") | |||
| animate_anti_join(x, y, by = "id")#' | |||
| } | |||
| # Save the results | |||
| \donttest{ | |||
| # to save the ggplot, use | |||
| fj <- animate_full_join(x, y, by = "id", export = "last") | |||
| ggsave("full-join.pdf", fj) | |||
| # to save the gif, use | |||
| fj <- animate_full_join(x, y, by = "id", export = "gif") | |||
| anim_save(fj, "full-join.gif") | |||
| } | |||
| } | |||
| \seealso{ | |||
| \code{\link[dplyr]{join}} | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_helpers.R | |||
| \name{animate_join_function} | |||
| \alias{animate_join_function} | |||
| \alias{animate_join} | |||
| \title{Animates a join - wrapper function} | |||
| \usage{ | |||
| animate_join(x, y, by, type, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{left dataset} | |||
| \item{y}{right dataset} | |||
| \item{by}{by arguments for the join} | |||
| \item{type}{type of the join, i.e., left_join, right_join, etc.} | |||
| \item{export}{if the function exports a gif, the first, or last picture} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a join - wrapper function | |||
| } | |||
| \examples{ | |||
| NULL | |||
| } | |||
| @@ -1,51 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_left_join} | |||
| \alias{animate_left_join} | |||
| \title{Animates a left join} | |||
| \usage{ | |||
| animate_left_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a left join | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_left_join(x, y, by = "id", export = "first") | |||
| animate_left_join(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| lj <- animate_left_join(x, y, by = "id", export = "last") | |||
| ggsave("left-join.pdf", lj) | |||
| animate_left_join(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| lj <- animate_left_join(x, y, by = "id", export = "gif") | |||
| anim_save(lj, "left-join.gif") | |||
| } | |||
| } | |||
| @@ -1,51 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_right_join} | |||
| \alias{animate_right_join} | |||
| \title{Animates a right join} | |||
| \usage{ | |||
| animate_right_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a right join | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_right_join(x, y, by = "id", export = "first") | |||
| animate_right_join(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| rj <- animate_right_join(x, y, by = "id", export = "last") | |||
| ggsave("right-join.pdf", rj) | |||
| animate_right_join(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| rj <- animate_right_join(x, y, by = "id", export = "gif") | |||
| anim_save(rj, "right-join.gif") | |||
| } | |||
| } | |||
| @@ -1,51 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_joins.R | |||
| \name{animate_semi_join} | |||
| \alias{animate_semi_join} | |||
| \title{Animates a semi join} | |||
| \usage{ | |||
| animate_semi_join(x, y, by, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{by}{the by arguments for the join} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a semi join | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_semi_join(x, y, by = "id", export = "first") | |||
| animate_semi_join(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| sj <- animate_semi_join(x, y, by = "id", export = "last") | |||
| ggsave("semi-join.pdf", sj) | |||
| animate_semi_join(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| sj <- animate_semi_join(x, y, by = "id", export = "gif") | |||
| anim_save(sj, "semi-join.gif") | |||
| } | |||
| } | |||
| @@ -1,28 +1,80 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_helpers.R | |||
| % Please edit documentation in R/animate_sets.R | |||
| \name{animate_set} | |||
| \alias{animate_set} | |||
| \title{Animates a set - wrapper function} | |||
| \alias{animate_union} | |||
| \alias{animate_union_all} | |||
| \alias{animate_intersect} | |||
| \alias{animate_setdiff} | |||
| \title{Animates a set operation} | |||
| \usage{ | |||
| animate_set(x, y, type, export = "gif", ...) | |||
| animate_union(x, y, export = "gif", ...) | |||
| animate_union_all(x, y, export = "gif", ...) | |||
| animate_intersect(x, y, export = "gif", ...) | |||
| animate_setdiff(x, y, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{left dataset} | |||
| \item{y}{right dataset} | |||
| \item{x}{the x dataset} | |||
| \item{type}{type of the set, i.e., intersect, setdiff, etc.} | |||
| \item{y}{the y dataset} | |||
| \item{export}{if the function exports a gif, the first, or last picture} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further arguments passed to base_plot} | |||
| \item{...}{further argument passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a set - wrapper function | |||
| Functions to visualise the set operations either static as a ggplot, or | |||
| dynamic as a gif. | |||
| } | |||
| \examples{ | |||
| NULL | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_union(x, y, by = "id", export = "first") | |||
| animate_union(x, y, by = "id", export = "last") | |||
| # Animate the first or last state of the join | |||
| animate_union(x, y, export = "first") | |||
| animate_union(x, y, export = "last") | |||
| # animate the transition as a gif (default) | |||
| \donttest{ | |||
| animate_union(x, y, export = "gif") | |||
| } | |||
| # different options include | |||
| \donttest{ | |||
| animate_union(x, y, by = "id") | |||
| animate_union_all(x, y, by = "id") | |||
| animate_intersect(x, y, by = "id") | |||
| animate_setdiff(x, y, by = "id") | |||
| } | |||
| # Save the results | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| un <- animate_union(x, y, by = "id", export = "last") | |||
| ggsave("union.pdf", un) | |||
| animate_union(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| un <- animate_union(x, y, by = "id", export = "gif") | |||
| anim_save(un, "union.gif") | |||
| } | |||
| } | |||
| \seealso{ | |||
| \code{\link[dplyr]{setops}} | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_helpers.R | |||
| \name{animate_set_function} | |||
| \alias{animate_set_function} | |||
| \alias{animate_set} | |||
| \title{Animates a set - wrapper function} | |||
| \usage{ | |||
| animate_set(x, y, type, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{left dataset} | |||
| \item{y}{right dataset} | |||
| \item{type}{type of the set, i.e., intersect, setdiff, etc.} | |||
| \item{export}{if the function exports a gif, the first, or last picture} | |||
| \item{...}{further arguments passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a set - wrapper function | |||
| } | |||
| \examples{ | |||
| NULL | |||
| } | |||
| @@ -1,49 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_sets.R | |||
| \name{animate_setdiff} | |||
| \alias{animate_setdiff} | |||
| \title{Animates a setdiff set} | |||
| \usage{ | |||
| animate_setdiff(x, y, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further argument passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a setdiff set | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_setdiff(x, y, by = "id", export = "first") | |||
| animate_setdiff(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| setd <- animate_setdiff(x, y, by = "id", export = "last") | |||
| ggsave("setdiff.pdf", setd) | |||
| animate_setdiff(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| setd <- animate_union_all(x, y, by = "id", export = "gif") | |||
| anim_save(setd, "setdiff.gif") | |||
| } | |||
| } | |||
| @@ -1,49 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_sets.R | |||
| \name{animate_union} | |||
| \alias{animate_union} | |||
| \title{Animates a union set} | |||
| \usage{ | |||
| animate_union(x, y, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further argument passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a union set | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_union(x, y, by = "id", export = "first") | |||
| animate_union(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| un <- animate_union(x, y, by = "id", export = "last") | |||
| ggsave("union.pdf", un) | |||
| animate_union(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| un <- animate_union(x, y, by = "id", export = "gif") | |||
| anim_save(un, "union.gif") | |||
| } | |||
| } | |||
| @@ -1,49 +0,0 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/animate_sets.R | |||
| \name{animate_union_all} | |||
| \alias{animate_union_all} | |||
| \title{Animates a union-all set} | |||
| \usage{ | |||
| animate_union_all(x, y, export = "gif", ...) | |||
| } | |||
| \arguments{ | |||
| \item{x}{the x dataset} | |||
| \item{y}{the y dataset} | |||
| \item{export}{the export type, either gif, first or last. The latter two | |||
| export ggplots of the first/last state of the join} | |||
| \item{...}{further argument passed to base_plot} | |||
| } | |||
| \value{ | |||
| either a gif or a ggplot | |||
| } | |||
| \description{ | |||
| Animates a union-all set | |||
| } | |||
| \examples{ | |||
| x <- data_frame( | |||
| id = 1:3, | |||
| x = paste0("x", 1:3) | |||
| ) | |||
| y <- data_frame( | |||
| id = (1:4)[-3], | |||
| y = paste0("y", (1:4)[-3]) | |||
| ) | |||
| animate_union_all(x, y, by = "id", export = "first") | |||
| animate_union_all(x, y, by = "id", export = "last") | |||
| \dontrun{ | |||
| # to save the ggplot, use | |||
| un <- animate_union_all(x, y, by = "id", export = "last") | |||
| ggsave("union-all.pdf", un) | |||
| animate_union_all(x, y, by = "id", export = "gif") | |||
| # to save the gif, use | |||
| un <- animate_union_all(x, y, by = "id", export = "gif") | |||
| anim_save(un, "union-all.gif") | |||
| } | |||
| } | |||
| @@ -1,10 +1,10 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/combine.R | |||
| \name{combine} | |||
| \alias{combine} | |||
| % Please edit documentation in R/move_together.R | |||
| \name{move_together} | |||
| \alias{move_together} | |||
| \title{Combines two processed datasets and combines them for a given method} | |||
| \usage{ | |||
| combine(lhs, rhs, type) | |||
| move_together(lhs, rhs, type) | |||
| } | |||
| \arguments{ | |||
| \item{lhs}{the left-hand side dataset} | |||