R/tableaumultiv.R

Defines functions tabmmph

Documented in tabmmph

#' Tableau multivarie
#'
#' @param ll Regression logistique
#' @param titre Titre - "Analyse multivariee" by default
#' @param lab  Label - "tabmulti" by default
#' @param export TRUE : export csv (FALSE by default)
<<<<<<< HEAD
#' @param ka TRUE : sortie via kable sinon xtable (FALSE  par defaut)
=======
#' @param ka TRUE : sortie via kable sinon xtable (TRUE  par defaut)
>>>>>>> 42b20b896837efe579944162827a68963584f331
#'
#' @return un tableau LaTeX , tableau csv
#'
#' @import xtable
#' @import epiDisplay
#' @import stats
#' @import knitr
#' @import kableExtra
#' @import utils
#'
#' @examples mydata <- lm(carb~wt + am, data= mtcars)
#' tabmmph(ll =  mydata,titre = "Analyse multivariée", lab = "tabmulti", export = FALSE, ka = TRUE)
#'
#' @export
<<<<<<< HEAD
tabmmph <- function(ll ,titre = "Analyse multivariée", lab = "tabmulti", export = FALSE, ka = FALSE){
=======
tabmmph <- function(ll ,titre = "Analyse multivariée", lab = "tabmulti", export = FALSE, ka = TRUE){
>>>>>>> 42b20b896837efe579944162827a68963584f331
  tbf <- c()
  llx <- logistic.display(ll,simplified = TRUE)$table
  rn <- rownames(llx)
  llx <- signif(llx,3)
  for (nl in 1:length(rn)){
    ic<- paste0("[",llx[nl,2]," ; ",llx[nl,3],"]")
    lf <- c(rn[nl],llx[nl,1],ic,llx[nl,4])
    tbf <- rbind(tbf,lf)
  }
  # Export
  if (export == 1){
    write.csv(tbf,"export_comparatif_multi.csv")
  }
  tbf[,1]<- chartr("_"," ",tbf[,1])
  #
  ltit <- c(" ","Odd-Ratio","IC 95\\%","p")
  if(ka){
    kable(tbf,caption=titre,label=lab, col.names = ltit, row.names = FALSE)%>% 
<<<<<<< HEAD
      kable_styling(bootstrap_options = "striped", full_width = FALSE,
=======
      kableExtra::kable_styling(bootstrap_options = "striped", full_width = FALSE,
>>>>>>> 42b20b896837efe579944162827a68963584f331
                    position = "center")
  }else{
  xx <- xtable(tbf,caption=titre,label=lab)
  colnames(xx) <- ltit
  print(xx,
        include.colnames = TRUE,
        include.rownames = FALSE,
        floating = TRUE,
        booktabs = TRUE,
        sanitize.text.function = function(x){x}
  )
  }
}
philippemichel/thesisph documentation built on Dec. 22, 2020, 11:08 a.m.