Skip to content
Open
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 @@ -17,7 +17,7 @@ Imports:
survey,
survival,
xtable
RoxygenNote: 6.1.1
RoxygenNote: 7.1.1
Suggests:
rmarkdown
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(formatp)
export(hide_rows)
export(tabcoxph)
export(tabfreq)
export(tabfreq.svy)
Expand Down
24 changes: 24 additions & 0 deletions R/hide_rows.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' Hide rows of selected levels of dichotomous variables from a Table
#' (e.g. "no" category of Smoking)
#'
#' @param tab Data frame.
#' @param rows Character string with name of levels (rows) which should be hidden.
#'
#' @return Data frame which you can print in R (e.g. with \strong{xtable}'s
#' \code{\link[xtable]{xtable}} or \strong{knitr}'s \code{\link[knitr]{kable}}).
#'
#' @examples
#' # Compare age, sex, and race by treatment group
#' # Hide level "Male" of Variable "sex"
#' tabmulti(Age + Sex + Race ~ Group, data = tabdata) %>% hide_rows(rows = c("male")) %>% kable()
#'
#'
#' @export
hide_rows <- function(tab, rows, ...){

rows <- paste("\\ \\ \\ ", tolower(rows), sep = "")
tab <- tab[which(!tolower(tab$Variable) %in% rows),]

return(tab)

}
6 changes: 3 additions & 3 deletions R/tabfreq_svy.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ tabfreq.svy <- function(formula,
} else if (cell == "N") {
part1 <- rowsums.svycounts
} else if (cell == "col.percent") {
part1 <- percents
part1 <- paste(sprintf(spf, percents), sep = "")
}
if (parenth == "none") {
part2 <- NULL
Expand All @@ -233,9 +233,9 @@ tabfreq.svy <- function(formula,
} else if (parenth == "N") {
part2 <- rowsums.svycounts
} else if (parenth == "col.percent") {
part2 <- percents
part2 <- paste(" (", sprintf(spf, percents), ")", sep = "") #percents
} else if (parenth == "se") {
part2 <- ses
part2 <- paste("(", sprintf(spf, ses), ")", sep = "")
} else if (parenth == "ci") {
zcrit <- qnorm(p = 0.975)
lower <- percents - zcrit * ses
Expand Down
10 changes: 8 additions & 2 deletions man/formatp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/hide_rows.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/tab.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions man/tabcoxph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 26 additions & 9 deletions man/tabfreq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions man/tabfreq.svy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions man/tabgee.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions man/tabglm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions man/tabmeans.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions man/tabmeans.svy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 19 additions & 6 deletions man/tabmedians.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions man/tabmedians.svy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading