Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

145 lines
3.5KB

  1. #' Animates a union set
  2. #'
  3. #' @param x the x dataset
  4. #' @param y the y dataset
  5. #' @param export the export type, either gif, first or last. The latter two
  6. #' export ggplots of the first/last state of the join
  7. #' @param ... further argument passed to base_plot
  8. #'
  9. #' @return either a gif or a ggplot
  10. #' @export
  11. #'
  12. #' @examples
  13. #' x <- data_frame(
  14. #' id = 1:3,
  15. #' x = paste0("x", 1:3)
  16. #' )
  17. #' y <- data_frame(
  18. #' id = (1:4)[-3],
  19. #' y = paste0("y", (1:4)[-3])
  20. #' )
  21. #'
  22. #' animate_union(x, y, by = "id", export = "first")
  23. #' animate_union(x, y, by = "id", export = "last")
  24. #'
  25. #' \dontrun{
  26. #' # to save the ggplot, use
  27. #' un <- animate_union(x, y, by = "id", export = "last")
  28. #' ggsave("union.pdf", un)
  29. #'
  30. #' animate_union(x, y, by = "id", export = "gif")
  31. #' # to save the gif, use
  32. #' un <- animate_union(x, y, by = "id", export = "gif")
  33. #' anim_save(un, "union.gif")
  34. #' }
  35. #'
  36. animate_union <- function(x, y, export = "gif", ...) {
  37. animate_set(x, y, type = "union", export = export, ...)
  38. }
  39. #' Animates a union-all set
  40. #'
  41. #' @inheritParams animate_union
  42. #'
  43. #' @return either a gif or a ggplot
  44. #' @export
  45. #'
  46. #' @examples
  47. #' x <- data_frame(
  48. #' id = 1:3,
  49. #' x = paste0("x", 1:3)
  50. #' )
  51. #' y <- data_frame(
  52. #' id = (1:4)[-3],
  53. #' y = paste0("y", (1:4)[-3])
  54. #' )
  55. #'
  56. #' animate_union_all(x, y, by = "id", export = "first")
  57. #' animate_union_all(x, y, by = "id", export = "last")
  58. #'
  59. #' \dontrun{
  60. #' # to save the ggplot, use
  61. #' un <- animate_union_all(x, y, by = "id", export = "last")
  62. #' ggsave("union-all.pdf", un)
  63. #'
  64. #' animate_union_all(x, y, by = "id", export = "gif")
  65. #' # to save the gif, use
  66. #' un <- animate_union_all(x, y, by = "id", export = "gif")
  67. #' anim_save(un, "union-all.gif")
  68. #' }
  69. #'
  70. animate_union_all <- function(x, y, export = "gif", ...) {
  71. animate_set(x, y, type = "union_all", export = export, ...)
  72. }
  73. #' Animates an intersect set
  74. #'
  75. #' @inheritParams animate_union
  76. #'
  77. #' @return either a gif or a ggplot
  78. #' @export
  79. #'
  80. #' @examples
  81. #' x <- data_frame(
  82. #' id = 1:3,
  83. #' x = paste0("x", 1:3)
  84. #' )
  85. #' y <- data_frame(
  86. #' id = (1:4)[-3],
  87. #' y = paste0("y", (1:4)[-3])
  88. #' )
  89. #'
  90. #' animate_intersect(x, y, by = "id", export = "first")
  91. #' animate_intersect(x, y, by = "id", export = "last")
  92. #'
  93. #' \dontrun{
  94. #' # to save the ggplot, use
  95. #' ints <- animate_intersect(x, y, by = "id", export = "last")
  96. #' ggsave("intersect.pdf", ints)
  97. #'
  98. #' animate_intersect(x, y, by = "id", export = "gif")
  99. #' # to save the gif, use
  100. #' ints <- animate_union_all(x, y, by = "id", export = "gif")
  101. #' anim_save(ints, "intersect.gif")
  102. #' }
  103. #'
  104. animate_intersect <- function(x, y, export = "gif", ...) {
  105. animate_set(x, y, type = "intersect", export = export, ...)
  106. }
  107. #' Animates a setdiff set
  108. #'
  109. #' @inheritParams animate_union
  110. #'
  111. #' @return either a gif or a ggplot
  112. #' @export
  113. #'
  114. #' @examples
  115. #' x <- data_frame(
  116. #' id = 1:3,
  117. #' x = paste0("x", 1:3)
  118. #' )
  119. #' y <- data_frame(
  120. #' id = (1:4)[-3],
  121. #' y = paste0("y", (1:4)[-3])
  122. #' )
  123. #'
  124. #' animate_setdiff(x, y, by = "id", export = "first")
  125. #' animate_setdiff(x, y, by = "id", export = "last")
  126. #'
  127. #' \dontrun{
  128. #' # to save the ggplot, use
  129. #' setd <- animate_setdiff(x, y, by = "id", export = "last")
  130. #' ggsave("setdiff.pdf", setd)
  131. #'
  132. #' animate_setdiff(x, y, by = "id", export = "gif")
  133. #' # to save the gif, use
  134. #' setd <- animate_union_all(x, y, by = "id", export = "gif")
  135. #' anim_save(setd, "setdiff.gif")
  136. #' }
  137. #'
  138. animate_setdiff <- function(x, y, export = "gif", ...) {
  139. animate_set(x, y, type = "setdiff", export = export, ...)
  140. }