Skip to content

Commit

Permalink
cran 1.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jinseob2kim committed Feb 29, 2024
1 parent 1392157 commit 7d55240
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Description: Create regression tables from generalized linear model(GLM), genera
Depends: R (>= 3.4.0)
License: Apache License 2.0
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports: geepack, lme4, stats, data.table, labelled, tableone, coxme, survival (>= 3.0.0), survey, methods, dplyr, purrr, magrittr, tibble
URL: https://github.com/jinseob2kim/jstable
BugReports: https://github.com/jinseob2kim/jstable/issues
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ importFrom(stats,glm)
importFrom(stats,kruskal.test)
importFrom(stats,oneway.test)
importFrom(stats,pnorm)
importFrom(stats,poisson)
importFrom(stats,predict)
importFrom(stats,qnorm)
importFrom(stats,quasibinomial)
importFrom(stats,quasipoisson)
importFrom(stats,update)
importFrom(survey,regTermTest)
importFrom(survey,svycoxph)
Expand Down
4 changes: 2 additions & 2 deletions R/coxme.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ coxmeTable <- function(mod) {
#' fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung)
#' jstable:::coxExp(jstable:::coxmeTable(fit))
#' @rdname coxExp
#' @importFrom stats pnorm
#' @importFrom stats pnorm qnorm

coxExp <- function(cox.coef, dec) {
HR <- paste(round(exp(cox.coef[, 1]), dec), " (", round(exp(cox.coef[, 1] - 1.96 * cox.coef[, 2]), dec), ",", round(exp(cox.coef[, 1] + 1.96 * cox.coef[, 2]), dec), ")", sep = "")
HR <- paste(round(exp(cox.coef[, 1]), dec), " (", round(exp(cox.coef[, 1] - stats::qnorm(0.975) * cox.coef[, 2]), dec), ",", round(exp(cox.coef[, 1] + stats::qnorm(0.975) * cox.coef[, 2]), dec), ")", sep = "")
pv <- cox.coef[, "p"]
# pv = 2*(1-pnorm(abs(cox.coef[, "z"])))
return(cbind(HR, pv))
Expand Down
6 changes: 3 additions & 3 deletions R/forestglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#' @importFrom dplyr group_split select filter mutate bind_cols
#' @importFrom magrittr %>%
#' @importFrom survey svyglm
#' @importFrom stats glm coefficients anova gaussian quasibinomial
#' @importFrom stats glm coefficients anova gaussian quasibinomial poisson quasipoisson qnorm
#' @importFrom utils tail

TableSubgroupGLM <- function(formula, var_subgroup = NULL, var_cov = NULL, data, family = "binomial", decimal.estimate = 2, decimal.percent = 1, decimal.pvalue = 3) {
Expand Down Expand Up @@ -158,7 +158,7 @@ TableSubgroupGLM <- function(formula, var_subgroup = NULL, var_cov = NULL, data,
purrr::map(~ possible_glm(formula, data = ., x = T, family = family)) -> model
data %>%
subset(!is.na(get(var_subgroup))) %>%
select(all_of(var_subgroup)) %>%
select(dplyr::all_of(var_subgroup)) %>%
table() %>%
names() -> label_val
xlev <- stats::glm(formula, data = data)$xlevels
Expand Down Expand Up @@ -186,7 +186,7 @@ TableSubgroupGLM <- function(formula, var_subgroup = NULL, var_cov = NULL, data,
CI0 <- model %>%
purrr::map(function(model) {
cc0 <- summary(model)$coefficients
c(cc0[2, 1] - qnorm(0.975) * cc0[2, 2], cc0[2, 1] + qnorm(0.975) * cc0[2, 2])
c(cc0[2, 1] - stats::qnorm(0.975) * cc0[2, 2], cc0[2, 1] + stats::qnorm(0.975) * cc0[2, 2])
}) %>%
Reduce(rbind, .)
Point.Estimate <- round(Estimate, decimal.estimate)
Expand Down
1 change: 0 additions & 1 deletion man/TableSubgroupGLM.Rd

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

1 change: 1 addition & 0 deletions man/coefNA.Rd

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

2 changes: 1 addition & 1 deletion man/mort.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-forestglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_that("Run TableSubgroupMultiGLM", {
) -> lung

expect_is(TableSubgroupMultiGLM(status ~ sex, data = lung, family = "binomial"), "data.frame")
expect_warning(TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), data = lung, family = "binomial"))
expect_is(TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), data = lung, family = "binomial"), "data.frame")
expect_is(TableSubgroupMultiGLM(pat.karno ~ sex, var_subgroups = c("kk", "kk1"), data = lung, family = "gaussian", line = TRUE), "data.frame")

## Survey data
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-regtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("Run glmshow.display", {

test_that("Run cox2.display", {
library(survival)
data(lung)
#data(lung)
fit0 <- coxph(Surv(time, status) ~ ph.ecog + age, data = lung, model = TRUE)
fit1 <- coxph(Surv(time, status) ~ ph.ecog + age + cluster(inst), data = lung, model = TRUE)
fit2 <- coxph(Surv(time, status) ~ ph.ecog + age + frailty(inst), data = lung, model = TRUE)
Expand Down

0 comments on commit 7d55240

Please sign in to comment.