Skip to content

Commit

Permalink
remove the tibble dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Sep 16, 2024
1 parent 2c93aeb commit 0895deb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Imports:
methods,
rlang (>= 1.1.0),
stats,
tibble,
tidyr
Suggests:
gridGraphics,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

* add return value docs for exported function or methods

* {tibble} is now removed from the dependency

# ggalign 0.0.2

* omit the redudnant description and add single quote for package name
Expand Down
4 changes: 3 additions & 1 deletion R/align-gg.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ AlignGG <- ggproto("AlignGG", Align,
if (is.matrix(data)) {
data <- melt_matrix(data)
} else {
data <- as_tibble0(data, rownames = ".row_names")
if (!is.null(old_rownames <- rownames(data))) {
data$.row_names <- old_rownames
}
data$.row_index <- seq_len(nrow(data))
}
data
Expand Down
20 changes: 9 additions & 11 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ to_matrix_axis <- function(direction) {
melt_matrix <- function(matrix) {
row_nms <- rownames(matrix)
col_nms <- colnames(matrix)
data <- as_tibble0(matrix, rownames = NULL) # nolint
data <- as_data_frame0(matrix) # nolint
colnames(data) <- seq_len(ncol(data))
data$.row_index <- seq_len(nrow(data))
data <- tidyr::pivot_longer(data,
Expand All @@ -179,23 +179,21 @@ fct_rev <- function(x) {
factor(ans, levels = rev(levels(ans)))
}

data_frame0 <- function(...) {
quickdf(list(...))
}

quickdf <- function(x) {
class(x) <- "data.frame"
attr(x, "row.names") <- .set_row_names(length(.subset2(x, 1L)))
x
}

tibble0 <- function(...) {
tibble::tibble(..., .name_repair = "minimal")
data_frame0 <- function(...) quickdf(list(...))
as_data_frame0 <- function(data, ...) {
as.data.frame(
x = data, ...,
make.names = FALSE,
stringsAsFactors = FALSE,
fix.empty.names = FALSE
)
}

as_tibble0 <- function(data, ...) {
tibble::as_tibble(data, ..., .name_repair = "minimal")
}

imap <- function(.x, .f, ...) {
nms <- names(.x)
Expand Down

0 comments on commit 0895deb

Please sign in to comment.