Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix console printing #814

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Imports:
rlang (>= 1.1.0),
tidyselect (>= 1.2.0),
vctrs (>= 0.6.0)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
URL: https://markfairbanks.github.io/tidytable/, https://github.com/markfairbanks/tidytable
Expand Down
8 changes: 2 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ S3method(pivot_longer,data.frame)
S3method(pivot_longer,tidytable)
S3method(pivot_wider,data.frame)
S3method(pivot_wider,tidytable)
S3method(print,grouped_tt)
S3method(print,rowwise_tt)
S3method(print,tidytable)
S3method(relocate,data.frame)
S3method(relocate,tidytable)
S3method(rename,data.frame)
Expand Down Expand Up @@ -106,10 +103,9 @@ S3method(summarize,data.frame)
S3method(summarize,grouped_tt)
S3method(summarize,rowwise_tt)
S3method(summarize,tidytable)
S3method(tbl_sum,grouped_tt_print)
S3method(tbl_sum,rowwise_tt_print)
S3method(tbl_sum,grouped_tt)
S3method(tbl_sum,rowwise_tt)
S3method(tbl_sum,tidytable)
S3method(tbl_sum,tidytable_print)
S3method(top_n,data.frame)
S3method(top_n,tidytable)
S3method(uncount,data.frame)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Attempting to rename columns using `group_by()` now leads to an error (#799)
* `pmap()` family works with data frame inputs (#803)
* `filter()` properly handles when comparing to `NA` when `.by` is used (#812)
* `paged.print` has been removed since it was breaking console printing (#810)

# tidytable 0.11.0

Expand Down
2 changes: 1 addition & 1 deletion R/new_tidytable.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
#'
#' new_tidytable(l)
new_tidytable <- function(x = list()) {
new_data_frame(x, class = c("tidytable", "data.table"))
new_data_frame(x, class = c("tidytable", "tbl", "data.table"))
}
34 changes: 2 additions & 32 deletions R/print.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
# tidytable ---------------------------
#' @export
print.tidytable <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) {
y <- set_class(x, print_class("tidytable_print"))
print(y, ..., n = n, width = width, n_extra = n_extra)
invisible(x)
}

#' @export
tbl_sum.tidytable <- function(x) {
c("A tidytable" = dim_desc(x))
}

#' @export
tbl_sum.tidytable_print <- function(x) {
c("A tidytable" = dim_desc(x))
}

#' @export
vec_ptype_abbr.tidytable <- function(x, ..., prefix_named = FALSE, suffix_shape = TRUE) {
"tidytable"
}

# grouped_tt ---------------------------
#' @export
print.grouped_tt <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) {
y <- set_class(x, print_class("grouped_tt_print"))
print(y, ..., n = n, width = width, n_extra = n_extra)
invisible(x)
}

#' @export
tbl_sum.grouped_tt_print <- function(x) {
tbl_sum.grouped_tt <- function(x) {
groups <- glue_collapse(group_vars(x), sep = ", ")
c("A tidytable" = dim_desc(x), "Groups" = groups)
}
Expand All @@ -42,22 +23,11 @@ vec_ptype_abbr.grouped_tt <- function(x, ..., prefix_named = FALSE, suffix_shape

# rowwise_tt ---------------------------
#' @export
print.rowwise_tt <- function(x, ..., n = NULL, width = NULL, n_extra = NULL) {
y <- set_class(x, print_class("rowwise_tt_print"))
print(y, ..., n = n, width = width, n_extra = n_extra)
invisible(x)
}

#' @export
tbl_sum.rowwise_tt_print <- function(x) {
tbl_sum.rowwise_tt <- function(x) {
c("A rowwise tidytable" = dim_desc(x))
}

#' @export
vec_ptype_abbr.rowwise_tt <- function(x, ..., prefix_named = FALSE, suffix_shape = TRUE) {
"rowwise_tt"
}

print_class <- function(.class) {
c("paged_df", .class, "tbl", tidytable_class())
}
2 changes: 1 addition & 1 deletion R/utils-general.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ get_dt_env <- function(x, ...) {
}

tidytable_class <- function() {
c("tidytable", "data.table", "data.frame")
c("tidytable", "tbl", "data.table", "data.frame")
}

# radix sort
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-as_tidytable.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test_that("works", {
.df <- as_tidytable(data.frame(x = 1:3, y = 1:3))
expect_named(.df, c("x", "y"))
expect_true(is_tidytable(.df))
expect_true(inherits(.df, "tbl"))

# data.table
.dt <- as_tidytable(data.table(x = 1:3, y = 1:3))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-new_tidytable.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ test_that("can create a tidytable from a list", {
out <- new_tidytable(l)
expect_named(out, c("x", "y"))
expect_true(is_tidytable(out))
expect_true(inherits(out, "tbl"))
})
Loading