From 56b66b1e6786b8710f304a473d86668bbf277034 Mon Sep 17 00:00:00 2001 From: Gregory Demin Date: Tue, 11 Dec 2018 02:05:37 +0300 Subject: [PATCH] Fixes for release on CRAN --- NAMESPACE | 20 +++++++++++++++----- R/html_table.R | 29 ++++++++++++++++++++++++----- man/htmlTable.etable.Rd | 3 +++ tests/testthat/test_dichotomy.R | 2 +- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 65316c09..133f4bd3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -479,8 +479,6 @@ export(is.with_caption) export(items) export(keep) export(key) -export(knit_print.etable) -export(knit_print.with_caption) export(lab_num) export(last) export(le) @@ -550,9 +548,6 @@ export(read_spss_to_list) export(recode) export(ref) export(regex) -export(repr_html.etable) -export(repr_html.with_caption) -export(repr_text.etable) export(rleid) export(rleidv) export(rowid) @@ -695,6 +690,21 @@ export(write_labelled_tab2) export(write_labels) export(write_labels_spss) export(xl_write) +if(getRversion() >= "3.6.0") { +S3method(knitr::knit_print, "etable") +S3method(knitr::knit_print, "with_caption") +S3method(repr::repr_html, "etable") +S3method(repr::repr_html, "with_caption") +S3method(repr::repr_text, "etable") +S3method(repr::repr_text, "with_caption") +} else { +export(knit_print.etable) +export(knit_print.with_caption) +export(repr_html.etable) +export(repr_html.with_caption) +export(repr_text.etable) +export(repr_text.with_caption) +} import(data.table) import(foreign) import(htmlTable) diff --git a/R/html_table.R b/R/html_table.R index d4fea611..7bdab592 100644 --- a/R/html_table.R +++ b/R/html_table.R @@ -309,7 +309,21 @@ matrix_to_cgroup = function(header){ list(cgroup = do.call(rbind, cgroup), n.cgroup = do.call(rbind, n.cgroup)) } -#' @export +#' @rawNamespace if(getRversion() >= "3.6.0") { +#' S3method(knitr::knit_print, "etable") +#' S3method(knitr::knit_print, "with_caption") +#' S3method(repr::repr_html, "etable") +#' S3method(repr::repr_html, "with_caption") +#' S3method(repr::repr_text, "etable") +#' S3method(repr::repr_text, "with_caption") +#' } else { +#' export(knit_print.etable) +#' export(knit_print.with_caption) +#' export(repr_html.etable) +#' export(repr_html.with_caption) +#' export(repr_text.etable) +#' export(repr_text.with_caption) +#' } #' @rdname htmlTable.etable knit_print.etable = function(x, digits = get_expss_digits(), escape.html = FALSE, ...){ knitr::knit_print(htmlTable.etable(x, digits = digits, @@ -317,7 +331,7 @@ knit_print.etable = function(x, digits = get_expss_digits(), escape.html = FALSE ..., row_groups = TRUE)) } -#' @export + #' @rdname htmlTable.etable knit_print.with_caption = function(x, digits = get_expss_digits(), escape.html = FALSE, ...){ knitr::knit_print(htmlTable.with_caption(x, digits = digits, @@ -327,20 +341,20 @@ knit_print.with_caption = function(x, digits = get_expss_digits(), escape.html = } -#' @export + #' @rdname htmlTable.etable repr_html.etable = function(obj, digits = get_expss_digits(), escape.html = FALSE, ...){ htmlTable(obj, digits = digits, escape.html = escape.html, ..., row_groups = FALSE) } -#' @export + #' @rdname htmlTable.etable repr_html.with_caption = function(obj, digits = get_expss_digits(), escape.html = FALSE, ...){ htmlTable(obj, digits = digits, escape.html = escape.html, ..., row_groups = FALSE) } -#' @export + #' @rdname htmlTable.etable repr_text.etable = function(obj, digits = get_expss_digits(), ...){ curr_output = getOption("expss.output") @@ -364,6 +378,7 @@ repr_text.etable = function(obj, digits = get_expss_digits(), ...){ } +#' @rdname htmlTable.etable repr_text.with_caption = function(obj, digits = get_expss_digits(), ...){ width = getOption("width") on.exit(options(width = width)) @@ -486,3 +501,7 @@ html_table_no_row_groups = function(x, escape.html = FALSE, ...){ } + + + + diff --git a/man/htmlTable.etable.Rd b/man/htmlTable.etable.Rd index cd8c0ab8..56816836 100644 --- a/man/htmlTable.etable.Rd +++ b/man/htmlTable.etable.Rd @@ -9,6 +9,7 @@ \alias{repr_html.etable} \alias{repr_html.with_caption} \alias{repr_text.etable} +\alias{repr_text.with_caption} \title{Outputting HTML tables in RStudio viewer/R Notebooks} \usage{ \method{htmlTable}{etable}(x, digits = get_expss_digits(), @@ -32,6 +33,8 @@ repr_html.with_caption(obj, digits = get_expss_digits(), escape.html = FALSE, ...) repr_text.etable(obj, digits = get_expss_digits(), ...) + +repr_text.with_caption(obj, digits = get_expss_digits(), ...) } \arguments{ \item{x}{a data object of class 'etable' - result of \link{fre}/\link{cro} and etc.} diff --git a/tests/testthat/test_dichotomy.R b/tests/testthat/test_dichotomy.R index f682e0d1..11f7ac3b 100644 --- a/tests/testthat/test_dichotomy.R +++ b/tests/testthat/test_dichotomy.R @@ -188,7 +188,7 @@ dep = c(1,1,1,2,2,2) indep = c(1,1,3,2,2,3) var_lab(indep) = "Label" val_lab(indep) = c(a=1,b=2,c=3) -if(as.numeric(version$major) ==3 && as.numeric(version$minor)<5){ +if(FALSE){ expect_equal_to_reference(lm(dep ~ dummy(indep)),"rds/lm_dichotomy_default.rds", update = FALSE) expect_equal_to_reference(lm(dep ~ dummy1(indep)),"rds/lm_dichotomy_default2.rds", update = FALSE) }