Преглед изворни кода

renamed some helper functions

this makes it easier to differentiate between the join-related and the (coming) tidyr-related functions that have similar goals
pull/10/head
David пре 7 година
родитељ
комит
3b19e34033
5 измењених фајлова са 18 додато и 18 уклоњено
  1. +3
    -3
      R/animate_helpers.R
  2. +6
    -6
      R/process_data_helpers.R
  3. +3
    -3
      man/add_color_join.Rd
  4. +3
    -3
      man/process_data_join.Rd
  5. +3
    -3
      man/process_join.Rd

+ 3
- 3
R/animate_helpers.R Прегледај датотеку

@@ -34,12 +34,12 @@ animate_set <- function(x, y, type, export = "gif", ...) {
}

if (type == "union_all") {
ll <- preprocess_data(x, y, by = names(x), fill = FALSE, ...)
ll <- process_join(x, y, by = names(x), fill = FALSE, ...)
ll <- lapply(ll, function(a)
a %>% mutate(.id_long = paste(.id_long, .side, sep = "-"))
)
} else {
ll <- preprocess_data(x, y, by = names(x), ...)
ll <- process_join(x, y, by = names(x), ...)
}

step0 <- bind_rows(ll$x, ll$y) %>% mutate(.frame = 0, .alpha = 1)
@@ -96,7 +96,7 @@ animate_join <- function(x, y, by, type, export = "gif", ...) {
y <- dplyr::distinct(y)
}

ll <- preprocess_data(x, y, by, ...)
ll <- process_join(x, y, by, ...)

step0 <- bind_rows(ll$x, ll$y) %>% mutate(.frame = 0, .alpha = 1)


+ 6
- 6
R/process_data_helpers.R Прегледај датотеку

@@ -11,7 +11,7 @@
#'
#' @examples
#' NULL
preprocess_data <- function(x, y, by, fill = TRUE, ...) {
process_join <- function(x, y, by, fill = TRUE, ...) {

#' test for
#' a <- c("unique", "mult", "mult", "also unique")
@@ -34,8 +34,8 @@ preprocess_data <- function(x, y, by, fill = TRUE, ...) {
ids <- dplyr::union(x %>% dplyr::select(.id, .id_long),
y %>% dplyr::select(.id, .id_long))

x_ <- process_data(x, ids, by, fill = fill, ...)
y_ <- process_data(y, ids, by, fill = fill, ...) %>%
x_ <- process_data_join(x, ids, by, fill = fill, ...)
y_ <- process_data_join(y, ids, by, fill = fill, ...) %>%
mutate(.x = .x + ncol(x) - 1)

return(list(x = x_, y = y_))
@@ -56,7 +56,7 @@ preprocess_data <- function(x, y, by, fill = TRUE, ...) {
#'
#' @examples
#' NULL
process_data <- function(x, ids, by, width = 1, side = NA, fill = TRUE, ...) {
process_data_join <- function(x, ids, by, width = 1, side = NA, fill = TRUE, ...) {
if (is.na(side)) side <- deparse(substitute(x))

x_names <- names(x) %>% str_subset("^[^\\.]")
@@ -101,7 +101,7 @@ process_data <- function(x, ids, by, width = 1, side = NA, fill = TRUE, ...) {
}
}

res <- add_color(x, rev(ids$.id), by, ...)
res <- add_color_join(x, rev(ids$.id), by, ...)
return(res)
}

@@ -122,7 +122,7 @@ process_data <- function(x, ids, by, width = 1, side = NA, fill = TRUE, ...) {
#'
#' @examples
#' NULL
add_color <- function(x, ids, by,
add_color_join <- function(x, ids, by,
color_header = "#737373", color_other = "#d0d0d0",
color_missing = "#ffffff",
color_fun = scales::brewer_pal(type = "qual", "Set1"),

man/add_color.Rd → man/add_color_join.Rd Прегледај датотеку

@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/process_data_helpers.R
\name{add_color}
\alias{add_color}
\name{add_color_join}
\alias{add_color_join}
\title{Adds Color to a processed data_frame}
\usage{
add_color(x, ids, by, color_header = "#737373",
add_color_join(x, ids, by, color_header = "#737373",
color_other = "#d0d0d0", color_missing = "#ffffff",
color_fun = scales::brewer_pal(type = "qual", "Set1"),
text_color = NA, ...)

man/process_data.Rd → man/process_data_join.Rd Прегледај датотеку

@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/process_data_helpers.R
\name{process_data}
\alias{process_data}
\name{process_data_join}
\alias{process_data_join}
\title{Processes the data}
\usage{
process_data(x, ids, by, width = 1, side = NA, fill = TRUE, ...)
process_data_join(x, ids, by, width = 1, side = NA, fill = TRUE, ...)
}
\arguments{
\item{x}{a preprocessed dataset}

man/preprocess_data.Rd → man/process_join.Rd Прегледај датотеку

@@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/process_data_helpers.R
\name{preprocess_data}
\alias{preprocess_data}
\name{process_join}
\alias{process_join}
\title{Preprocess data}
\usage{
preprocess_data(x, y, by, fill = TRUE, ...)
process_join(x, y, by, fill = TRUE, ...)
}
\arguments{
\item{x}{a left dataset}

Loading…
Откажи
Сачувај