Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed Mar 6, 2024
1 parent f70baa1 commit 86255ef
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions R/paginate_listing.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ paginate_listing <- function(lsting,
tf_wrap = !is.null(max_width),
max_width = NULL,
verbose = FALSE) {
# process lists of listings
if (!is(lsting, "listing_df")) {
# process lists of listings
checkmate::assert_true(all(unlist(lapply(lsting, is, "listing_df"))))
if (!"colwidths" %in% as.list(match.call())) {
all_colwidths <- lapply(lsting, propose_column_widths)
Expand All @@ -72,58 +72,58 @@ paginate_listing <- function(lsting,
)

ret <- unlist(lsting_list, recursive = FALSE)
ret
} else {
checkmate::assert_flag(tf_wrap)
checkmate::assert_count(max_width, null.ok = TRUE)
checkmate::assert_flag(verbose)
checkmate::assert_class(lsting, "listing_df")
checkmate::assert_numeric(colwidths, lower = 0, len = length(listing_dispcols(lsting)), null.ok = TRUE)
return(ret)
}

indx <- paginate_indices(lsting,
page_type = page_type,
font_family = font_family,
font_size = font_size,
lineheight = lineheight,
landscape = landscape,
pg_width = pg_width,
pg_height = pg_height,
margins = margins,
lpp = lpp,
cpp = cpp,
colwidths = colwidths,
tf_wrap = tf_wrap,
max_width = max_width,
rep_cols = length(get_keycols(lsting)),
verbose = verbose
)
checkmate::assert_flag(tf_wrap)
checkmate::assert_count(max_width, null.ok = TRUE)
checkmate::assert_flag(verbose)
checkmate::assert_class(lsting, "listing_df")
checkmate::assert_numeric(colwidths, lower = 0, len = length(listing_dispcols(lsting)), null.ok = TRUE)

vert_pags <- lapply(
indx$pag_row_indices,
function(ii) lsting[ii, ]
)
dispnames <- listing_dispcols(lsting)
full_pag <- lapply(
vert_pags,
function(onepag) {
if (!is.null(indx$pag_col_indices)) {
lapply(
indx$pag_col_indices,
function(jj) {
res <- onepag[, dispnames[jj], drop = FALSE]
listing_dispcols(res) <- intersect(dispnames, names(res))
res
}
)
} else {
list(onepag)
}
indx <- paginate_indices(lsting,
page_type = page_type,
font_family = font_family,
font_size = font_size,
lineheight = lineheight,
landscape = landscape,
pg_width = pg_width,
pg_height = pg_height,
margins = margins,
lpp = lpp,
cpp = cpp,
colwidths = colwidths,
tf_wrap = tf_wrap,
max_width = max_width,
rep_cols = length(get_keycols(lsting)),
verbose = verbose
)

vert_pags <- lapply(
indx$pag_row_indices,
function(ii) lsting[ii, ]
)
dispnames <- listing_dispcols(lsting)
full_pag <- lapply(
vert_pags,
function(onepag) {
if (!is.null(indx$pag_col_indices)) {
lapply(
indx$pag_col_indices,
function(jj) {
res <- onepag[, dispnames[jj], drop = FALSE]
listing_dispcols(res) <- intersect(dispnames, names(res))
res
}
)
} else {
list(onepag)
}
)
}
)

ret <- unlist(full_pag, recursive = FALSE)
ret
}
ret <- unlist(full_pag, recursive = FALSE)
ret
}

#' @title Defunct functions
Expand Down

0 comments on commit 86255ef

Please sign in to comment.