diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..48b12a4 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,79 @@ +# R-hub's genetic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/rhub2/blob/v1/inst/workflow/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub2::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }} (${{ github.event.inputs.id }}) + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/rhub2/actions/rhub-setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: actions/checkout@v3 + - uses: r-hub/rhub2/actions/rhub-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: actions/checkout@v3 + - uses: r-hub/rhub2/actions/rhub-setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/rhub2/actions/rhub-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/NAMESPACE b/NAMESPACE index c45084f..bc9ccad 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,10 +6,13 @@ export("%>%") export(as_flextable) export(as_paragraph_md) export(colformat_md) +export(flextable) export(footnote_options) export(separate_header) export(span_header) +export(split_header) export(with_blanks) importFrom(flextable,as_flextable) +importFrom(flextable,flextable) importFrom(magrittr,"%>%") importFrom(rlang,.data) diff --git a/NEWS.md b/NEWS.md index 4a983a6..4ae5074 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# ftExtra 0.6.1 + +* Deprecated functions masking the corresponding ones from the **flextable** package (#95) + +* Renamed `separate_header` to `split_header` (#95) + +* Fixed a wrong escape regex in the `sep` parameter of `split_header`, `span_header`, and `separate_header` (#95) + # ftExtra 0.6.0 * Fix `footnote_options` not controlling reference symbols correctly. Formerly, only symbols in the cells used the `prefix` and the `suffix` arguments. Now, footnote texts also respects them (#88). diff --git a/R/as-flextable.R b/R/as-flextable.R index 8a7d5c2..a780e18 100644 --- a/R/as-flextable.R +++ b/R/as-flextable.R @@ -51,7 +51,7 @@ as_flextable.grouped_df <- function( x %>% dplyr::ungroup() %>% flextable::as_grouped_data(g) %>% - as_flextable(...) + flextable::as_flextable(...) ) } @@ -79,6 +79,16 @@ as_flextable.grouped_df <- function( #' as_flextable() #' @export as_flextable.data.frame <- function(x, col_keys = names(x), ...) { + .Deprecated( + "flextable:::as_flextable.data.frame", + msg = paste( + "ftExtra:::as_flextable.data.frame is deprecated", + "and will be removed in the future release.", + "Consider using flextalbe's implementation by running", + '`.S3method("as_flextable", "data.frame",', + "flextable:::as_flextable.data.frame)`" + ) + ) if (is.function(col_keys)) col_keys <- col_keys(x) flextable::flextable(x, col_keys = col_keys, ...) } diff --git a/R/footnote.R b/R/footnote.R index 7cbe5ad..7533dda 100644 --- a/R/footnote.R +++ b/R/footnote.R @@ -22,7 +22,7 @@ #' #' @examples #' # A examole flextable with unprocessed markdown footnotes -#' ft <- as_flextable(tibble::tibble( +#' ft <- flextable(tibble::tibble( #' "header1^[note a]" = c("x^[note 1]", "y"), #' "header2" = c("a", "b^[note 2]") #' )) diff --git a/R/ftExtra.R b/R/ftExtra.R index 40a3184..54ad6b2 100644 --- a/R/ftExtra.R +++ b/R/ftExtra.R @@ -2,3 +2,7 @@ #' @importFrom magrittr %>% #' @export magrittr::`%>%` + +#' @importFrom flextable flextable +#' @export +flextable::flextable diff --git a/R/header-transform.R b/R/header-transform.R index b503053..b95ae30 100644 --- a/R/header-transform.R +++ b/R/header-transform.R @@ -59,7 +59,10 @@ transform_header <- function( flextable::fix_border_issues() } -#' Separate the header based on delimiters +#' Split the header based on delimiters +#' +#' @note +#' `split_header` is a rename of `separate_header` and the latter will be removed in the future release. #' #' @param x A `flextable` object` #' @inheritParams tidyr::separate @@ -72,12 +75,12 @@ transform_header <- function( #' #' @examples #' iris %>% -#' as_flextable() %>% +#' flextable() %>% #' separate_header() #' @export -separate_header <- function( +split_header <- function( x, - sep = "[_\\.]", + sep = "[_.]", theme_fun = NULL, ... ) { @@ -86,6 +89,27 @@ separate_header <- function( sep = sep, theme_fun = theme_fun, .fill = FALSE, .merge = FALSE, ... ) } + +#' @rdname split_header +#' @export +separate_header <- function( + x, + sep = "[_.]", + theme_fun = NULL, + ... +) { + .Deprecated( + "split_header", + msg = paste( + "ftExtra::separate_header will be removed in the future release", + "to avoid masking `flextable::separate_header`.", + "Instead, use ftExtra::split_header which is a copy of", + "ftExtra::separate_header." + ) + ) + split_header(x, sep, theme_fun, ...) +} + #' Span the header based on delimiters #' #' @inherit separate_header @@ -94,12 +118,12 @@ separate_header <- function( #' #' @examples #' iris %>% -#' as_flextable() %>% +#' flextable() %>% #' span_header() #' @export span_header <- function( x, - sep = "[_\\.]", + sep = "[_.]", theme_fun = NULL, ... ) { diff --git a/R/utils.R b/R/utils.R index 8a01add..5291750 100644 --- a/R/utils.R +++ b/R/utils.R @@ -16,3 +16,7 @@ drop_na <- function(x) { last <- function(x) { x[[length(x)]] } + +.Deprecated <- function(...) { + if (!getOption("ftExtra.ignore.deprecation", FALSE)) base::.Deprecated(...) +} diff --git a/R/with-blanks.R b/R/with-blanks.R index 4967fbb..26cf29d 100644 --- a/R/with-blanks.R +++ b/R/with-blanks.R @@ -6,7 +6,7 @@ insert_blanks <- function(after = NULL, before = NULL, data) { names(data), sprintf("..after%s", seq_along(.after)), sprintf("..before%s", seq_along(.before)) - )[order(c(seq(length(data)), .after, .before))] + )[order(c(seq_along(data), .after, .before))] } #' Specify blank columns easily via `col_keys` @@ -20,6 +20,9 @@ insert_blanks <- function(after = NULL, before = NULL, data) { #' as_flextable(col_keys = with_blanks(dplyr::ends_with("Width"))) #' @export with_blanks <- function(after = NULL, before = NULL) { + .Deprecated(msg = paste( + "This is a result of deprecating ftExtra:::as_flextable.data.frame" + )) after <- rlang::enquo(after) before <- rlang::enquo(before) function(data) insert_blanks(after = after, before = before, data = data) diff --git a/docs/articles/format_columns.html b/docs/articles/format_columns.html index 5e4b61f..023b0be 100644 --- a/docs/articles/format_columns.html +++ b/docs/articles/format_columns.html @@ -135,12 +135,12 @@