Codes for cross tables.^[See childRmd/_12crossTables.Rmd
file for other codes]
library(finalfit)
# dependent <- c("dependent1", # "dependent2" # ) # explanatory <- c("explanatory1", # "explanatory2" # ) dependent <- "PreinvasiveComponent" explanatory <- c("Sex", "Age", "Grade", "TStage")
Change column = TRUE
argument to get row or column percentages.
source(here::here("R", "gc_table_cross.R"))
CreateTableOne(vars = myVars, strata = "columnname", data = pbc, factorVars = catVars)
print(tab, nonnormal = biomarkers, exact = "exactVariable", smd = TRUE)
write2html( knitr::kable(head(mockstudy)), paste0(tmpdir, "/test.kable.keep.rmd.html"), quiet = TRUE, # passed to rmarkdown::render keep.rmd = TRUE )
ctable(tobacco$gender, tobacco$smoker, style = 'rmarkdown')
print(ctable(tobacco$gender, tobacco$smoker), method = 'render') print(ctable(tobacco$smoker, tobacco$diseased, prop = "r"), method = "render") with(tobacco, print(ctable(smoker, diseased, prop = 'n', totals = FALSE, chisq = TRUE), headings = FALSE, method = "render"))
# devtools::install_github("ewenharrison/summarizer") # library(summarizer) # data(colon_s) explanatory = c("age", "age.factor", "sex.factor", "obstruct.factor") dependent = "perfor.factor" colon_s %>% summary.factorlist(dependent, explanatory, p=TRUE) %>% knitr::kable(row.names=FALSE, align=c("l", "l", "r", "r", "r")) explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor") dependent = 'mort_5yr' colon_s %>% summary.factorlist(dependent, explanatory) %>% knitr::kable(row.names=FALSE, align=c("l", "l", "r", "r", "r"))
library(DT) datatable(mtcars, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )
library("rmngb") # rmngb::pairwise.chisq.test(mydata$StageGr2, mydata$Ki67Gr) rmngb::pairwise.fisher.test(mydata$StageGr2, mydata$Ki67Gr)
# rmngb::pairwise.chisq.test(mydata$LiverDistantMets, mydata$Ki67Gr, p.adj = "BH") rmngb::pairwise.fisher.test(mydata$LiverDistantMets, mydata$Ki67Gr, p.adj = "BH")
# rmngb::pairwise.chisq.test(mydata$PNI, mydata$Ki67Gr, p.adj = "BH") rmngb::pairwise.fisher.test(mydata$PNI, mydata$Ki67Gr, p.adj = "BH")
# rmngb::pairwise.chisq.test(mydata$LVI, mydata$Ki67Gr, p.adj = "BH") rmngb::pairwise.fisher.test(mydata$LVI, mydata$Ki67Gr, p.adj = "BH")
MBStudy <- tibble::tribble( ~Grup, ~Diagnosis, ~Number, "\"Grup1\"", "\"Diseased\"", 1383L, "\"Grup2A\"", "\"Diseased\"", 58L, "\"Grup2B\"", "\"Diseased\"", 349L, "\"Grup3\"", "\"Diseased\"", 5217L, "\"Grup1\"", "\"Stromal Diseased\"", 13L, "\"Grup2A\"", "\"Stromal Diseased\"", 2L, "\"Grup2B\"", "\"Stromal Diseased\"", 47L, "\"Grup3\"", "\"Stromal Diseased\"", 476L, "\"Grup1\"", "\"Inflammation fibrosis\"", 56L, "\"Grup2A\"", "\"Inflammation fibrosis\"", 52L, "\"Grup2B\"", "\"Inflammation fibrosis\"", 267L, "\"Grup3\"", "\"Inflammation fibrosis\"", 1387L )
MBStudy <- tibble::tribble( ~Grup, ~Diagnosis, ~Number, "\"Grup1\"", "\"Diseased\"", 1383L, "\"Grup2A\"", "\"Diseased\"", 58L, "\"Grup2B\"", "\"Diseased\"", 349L, "\"Grup3\"", "\"Diseased\"", 5217L, "\"Grup1\"", "\"Stromal Diseased\"", 13L, "\"Grup2A\"", "\"Stromal Diseased\"", 2L, "\"Grup2B\"", "\"Stromal Diseased\"", 47L, "\"Grup3\"", "\"Stromal Diseased\"", 476L, "\"Grup1\"", "\"Inflammation fibrosis\"", 56L, "\"Grup2A\"", "\"Inflammation fibrosis\"", 52L, "\"Grup2B\"", "\"Inflammation fibrosis\"", 267L, "\"Grup3\"", "\"Inflammation fibrosis\"", 1387L ) MBStudy <- data.frame( stringsAsFactors = FALSE, V1 = c("\"Grup1\"","\"Grup2A\"", "\"Grup2B\"","\"Grup3\"","\"Grup1\"","\"Grup2A\"", "\"Grup2B\"","\"Grup3\"","\"Grup1\"","\"Grup2A\"", "\"Grup2B\"","\"Grup3\""), V2 = c("\"Diseased\"", "\"Diseased\"","\"Diseased\"","\"Diseased\"", "\"Stromal Diseased\"","\"Stromal Diseased\"", "\"Stromal Diseased\"", "\"Stromal Diseased\"","\"Inflammation fibrosis\"", "\"Inflammation fibrosis\"","\"Inflammation fibrosis\"", "\"Inflammation fibrosis\""), V3 = c(1383L,58L,349L,5217L,13L, 2L,47L,476L,56L,52L,267L,1387L) ) MBStudy <- matrix(c( 1383L, 13L, 56L, 58L, 2L, 52L, 349L, 47L, 267L, 5217L, 476L, 1387L ), byrow = TRUE, nrow = 4, dimnames = list(c("Grup1", "Grup2A", "Grup2B", "Grup3"), c("Diseased", "Stromal Diseased", "Inflammation"))) RVAideMemoire::chisq.multcomp(MBStudy)
\newpage \blandscape
MBStudy
MB_table <- RVAideMemoire::fisher.multcomp(tab.cont = MBStudy) MB_table$p.value %>% as.data.frame() %>% tibble::rownames_to_column(var = "Grup") %>% gt::gt(.) %>% gt::fmt_number(., columns = dplyr::contains("Diseased"), decimals = 4)
\elandscape
rmngb::pairwise.fisher.test.table(MBStudy)
MBStudy2 <- matrix(c( 13L, 53L, 9L, 5L, 3L, 26L), byrow = TRUE, nrow = 3, dimnames = list( c("Diseased", "Inflammation", "Fibrosis"), c("sw", "cds") )) MBStudy2 MBStudy2_analysis <- RVAideMemoire::fisher.multcomp(tab.cont = t(MBStudy2)) MBStudy2_analysis$p.value
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.