Skip to content

Commit 0895deb

Browse files
committed
remove the tibble dependency
1 parent 2c93aeb commit 0895deb

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Imports:
2020
methods,
2121
rlang (>= 1.1.0),
2222
stats,
23-
tibble,
2423
tidyr
2524
Suggests:
2625
gridGraphics,

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
* add return value docs for exported function or methods
1010

11+
* {tibble} is now removed from the dependency
12+
1113
# ggalign 0.0.2
1214

1315
* omit the redudnant description and add single quote for package name

R/align-gg.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ AlignGG <- ggproto("AlignGG", Align,
7777
if (is.matrix(data)) {
7878
data <- melt_matrix(data)
7979
} else {
80-
data <- as_tibble0(data, rownames = ".row_names")
80+
if (!is.null(old_rownames <- rownames(data))) {
81+
data$.row_names <- old_rownames
82+
}
8183
data$.row_index <- seq_len(nrow(data))
8284
}
8385
data

R/utils.R

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ to_matrix_axis <- function(direction) {
160160
melt_matrix <- function(matrix) {
161161
row_nms <- rownames(matrix)
162162
col_nms <- colnames(matrix)
163-
data <- as_tibble0(matrix, rownames = NULL) # nolint
163+
data <- as_data_frame0(matrix) # nolint
164164
colnames(data) <- seq_len(ncol(data))
165165
data$.row_index <- seq_len(nrow(data))
166166
data <- tidyr::pivot_longer(data,
@@ -179,23 +179,21 @@ fct_rev <- function(x) {
179179
factor(ans, levels = rev(levels(ans)))
180180
}
181181

182-
data_frame0 <- function(...) {
183-
quickdf(list(...))
184-
}
185-
186182
quickdf <- function(x) {
187183
class(x) <- "data.frame"
188184
attr(x, "row.names") <- .set_row_names(length(.subset2(x, 1L)))
189185
x
190186
}
191-
192-
tibble0 <- function(...) {
193-
tibble::tibble(..., .name_repair = "minimal")
187+
data_frame0 <- function(...) quickdf(list(...))
188+
as_data_frame0 <- function(data, ...) {
189+
as.data.frame(
190+
x = data, ...,
191+
make.names = FALSE,
192+
stringsAsFactors = FALSE,
193+
fix.empty.names = FALSE
194+
)
194195
}
195196

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

200198
imap <- function(.x, .f, ...) {
201199
nms <- names(.x)

0 commit comments

Comments
 (0)