plot.subtitle = element_text(size = 12),
axis.title.x = element_blank(),
axis.title.y = element_text(
size = 12,
angle = 90,
vjust = .5
),
axis.text.x = element_text(
size = 12 ,
angle = 0,
hjust = 0.5
),
axis.text.y = element_text(size = 12),
legend.position = "none"
)
source("~/actif/novopsycovid/graphconf.R")
aa <- graphconfx(tt,rad.au.bon.moment,stress)
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
tabz <- graphconfx(tt,rad.au.bon.moment,stress)
tabz %>%
ggplot() +
aes(x = names, y = mean*100, fill = names) +
geom_bar(stat = "identity")
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
nn <- source("~/actif/novopsycovid/graphconf.R")
nn
source("~/actif/novopsycovid/graphconf.R")
nnx <- source("~/actif/novopsycovid/graphconf.R")
nnx
source("~/actif/novopsycovid/graphconf.R")
nnx <- source("~/actif/novopsycovid/graphconf.R")
nnx
nnx <- tt %>%
summarise(levels(stress))
nnx
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
source("~/actif/novopsycovid/graphconf.R")
graphconfx(tt,rad.au.bon.moment,stress)
graphconfx(zzx,rad.au.bon.moment,stress, "Stress & retour à domicile", tity = "% stress")
tabcx <- function(dfx,
tri,
nomv,
titre = "Tableau comparatif",
lab = "tabcomp",
export = FALSE) {
# On supprime les données manquantes dans la variable de tri
dfx <- as_tibble(dfx)
dfx <- dfx %>%
dplyr::filter(!is.na({{tri}}))
var2 <- "+ age+profession, data = tt, family = binomial)"
#
tabx <- NULL
nlig <- 0
ligd <- NULL
trix <- enquo(tri)
vv <- quo_name(trix)
triz <- dfx[vv]
triz <- triz[[1]]
for (ll in seq_len(length(dfx))) {
varx <- dfx[, ll]
varx <- varx[[1]]
if (names(dfx)[ll] != vv) {
nom <- paste0("<b>", nomv[ll], "</b>")
var1 <-  paste0("glm(",vv,"~")
aa <- paste0(var1,names(dfx)[ll],var2)
ll <- eval(parse(text = aa))
dd <- logistic.display(ll, simplified = TRUE)
dd <- dd$table
if (is.numeric(varx)) {
# Variables numériques
lig <- lignumc(nom, varx, triz)
lig <- c(lig,beaup(dd[1,4]))
tabx <- rbind(tabx, lig)
nlig <- nlig + 1
} else {
# Variables factorielles
if(is.factor(varx)==FALSE){
varx <- as.factor(varx)
}
lig <- ligfcx(nom, varx, triz,beaup(dd[1,4]))
tabx <- rbind(tabx, lig)
llx <- length(levels(varx))
nlig <- nlig + 1 + llx
ligd <- c(ligd, seq(nlig - llx + 1, nlig))
}
# Export
if (export) {
nomcsv <- paste0(titre, "_export_comparatif.csv")
write.csv(tabx, nomcsv)
}
# Création tableaux
ltit <- c(" ", levels(triz), "p brut", "p ajusté")
tabf <-   kable(
tabx,
row.names = FALSE,
col.names = ltit,
caption = titre,
label = lab,
escape = FALSE
) %>%
kable_styling(
bootstrap_options = "striped",
full_width = FALSE,
position = "center"
)
if (!is.null(ligd)) {add_indent(tabf, ligd)}
#tabf %>%
# scroll_box(width = "100%", height = "850px")
}
######
ligfcx <- function(nom, varp, trip ,bdd) {
tabp <- table(varp, trip)
chip <- chisq.test(tabp, correct = TRUE)[[3]]
chip <- chisq.test(tabp, correct = FALSE)
if (min(chip$expected)<5){chip <- chisq.test(tabp, correct = TRUE)}
chip <- chip[[3]]
if (is.na(chip)){
chip <- fisher.test(tabp)[[1]]
}
chip <- beaup(chip)
ltri <- length(levels(trip))
lvar <- length(levels(varp))
tabg <- c(nom, rep(" ", ltri), chip,bdd)
#
ss <- colSums(tabp)
for (lig in 1:lvar) {
ligt <- levels(varp)[lig]
for (cas in 1:ltri) {
casx <- tabp[lig, cas]
casp <- round(100*casx/ss[cas],1)
cast <- paste0(casx,"/",ss[cas]," (",casp," %)" )
ligt <- c(ligt,cast)
}
ligt <- c(ligt, " ", " ")
tabg <- rbind(tabg, ligt)
}
return(tabg)
}
##
graphconfx <- function(fdx,varx, vars, tit = " ", tity = "%") {
tabx <- fdx  %>%
summarise(tabx = table({{varx}},{{vars}}))
nnx <- fdx %>%
summarise(levels({{varx}}))
tabx <- as.matrix(tabx)
stabx <- rowSums(tabx)
tabo <- as.matrix(tabx)[,2]
tabz <- binom.confint(tabo,stabx, method = "exact")
tabz <- tibble(tabz[,4:6])
tabz <- bind_cols(tabz,nnx)
names(tabz)[4] <- "names"
#return(tabz)
#
tabz %>%
ggplot() +
aes(x = names, y = mean*100, fill = names) +
geom_bar(stat = "identity")  +
geom_errorbar(aes(ymin = lower * 100, ymax = upper * 100),
width = .2,
position = position_dodge(.9)) +
labs(title = tit,
subtitle = "",
y = tity,
caption = tit,
label = "stress1") +
theme_light() +
scale_fill_material() +
theme(
plot.title = element_text(size = 18, face = "bold"),
plot.subtitle = element_text(size = 12),
axis.title.x = element_blank(),
axis.title.y = element_text(
size = 12,
angle = 90,
vjust = .5
),
axis.text.x = element_text(
size = 12 ,
angle = 0,
hjust = 0.5
),
axis.text.y = element_text(size = 12),
legend.position = "none"
)
}
graphconfx(zzx,rad.au.bon.moment,stress, "Stress & retour à domicile", tity = "% stress")
names(tt)
graphconfx(zzx,rad.au.bon.moment,troubles.attentionnels, "Troubles.attentionnels & retour à domicile", tity = "% troubles.attentionnels")
graphconfx(zzx,rad.au.bon.moment,troubles.attentionnels, "Troubles.attentionnels & retour à domicile", titx = "Retour à domicile",tity = "% troubles.attentionnels")
tabcx <- function(dfx,
tri,
nomv,
titre = "Tableau comparatif",
lab = "tabcomp",
export = FALSE) {
# On supprime les données manquantes dans la variable de tri
dfx <- as_tibble(dfx)
dfx <- dfx %>%
dplyr::filter(!is.na({{tri}}))
var2 <- "+ age+profession, data = tt, family = binomial)"
#
tabx <- NULL
nlig <- 0
ligd <- NULL
trix <- enquo(tri)
vv <- quo_name(trix)
triz <- dfx[vv]
triz <- triz[[1]]
for (ll in seq_len(length(dfx))) {
varx <- dfx[, ll]
varx <- varx[[1]]
if (names(dfx)[ll] != vv) {
nom <- paste0("<b>", nomv[ll], "</b>")
var1 <-  paste0("glm(",vv,"~")
aa <- paste0(var1,names(dfx)[ll],var2)
ll <- eval(parse(text = aa))
dd <- logistic.display(ll, simplified = TRUE)
dd <- dd$table
if (is.numeric(varx)) {
# Variables numériques
lig <- lignumc(nom, varx, triz)
lig <- c(lig,beaup(dd[1,4]))
tabx <- rbind(tabx, lig)
nlig <- nlig + 1
} else {
# Variables factorielles
if(is.factor(varx)==FALSE){
varx <- as.factor(varx)
}
lig <- ligfcx(nom, varx, triz,beaup(dd[1,4]))
tabx <- rbind(tabx, lig)
llx <- length(levels(varx))
nlig <- nlig + 1 + llx
ligd <- c(ligd, seq(nlig - llx + 1, nlig))
}
# Export
if (export) {
nomcsv <- paste0(titre, "_export_comparatif.csv")
write.csv(tabx, nomcsv)
}
# Création tableaux
ltit <- c(" ", levels(triz), "p brut", "p ajusté")
tabf <-   kable(
tabx,
row.names = FALSE,
col.names = ltit,
caption = titre,
label = lab,
escape = FALSE
) %>%
kable_styling(
bootstrap_options = "striped",
full_width = FALSE,
position = "center"
)
if (!is.null(ligd)) {add_indent(tabf, ligd)}
#tabf %>%
# scroll_box(width = "100%", height = "850px")
}
######
ligfcx <- function(nom, varp, trip ,bdd) {
tabp <- table(varp, trip)
chip <- chisq.test(tabp, correct = TRUE)[[3]]
chip <- chisq.test(tabp, correct = FALSE)
if (min(chip$expected)<5){chip <- chisq.test(tabp, correct = TRUE)}
chip <- chip[[3]]
if (is.na(chip)){
chip <- fisher.test(tabp)[[1]]
}
chip <- beaup(chip)
ltri <- length(levels(trip))
lvar <- length(levels(varp))
tabg <- c(nom, rep(" ", ltri), chip,bdd)
#
ss <- colSums(tabp)
for (lig in 1:lvar) {
ligt <- levels(varp)[lig]
for (cas in 1:ltri) {
casx <- tabp[lig, cas]
casp <- round(100*casx/ss[cas],1)
cast <- paste0(casx,"/",ss[cas]," (",casp," %)" )
ligt <- c(ligt,cast)
}
ligt <- c(ligt, " ", " ")
tabg <- rbind(tabg, ligt)
}
return(tabg)
}
##
graphconfx <- function(fdx,varx, vars, tit = " ",titx= "", tity = "%") {
tabx <- fdx  %>%
summarise(tabx = table({{varx}},{{vars}}))
nnx <- fdx %>%
summarise(levels({{varx}}))
tabx <- as.matrix(tabx)
stabx <- rowSums(tabx)
tabo <- as.matrix(tabx)[,2]
tabz <- binom.confint(tabo,stabx, method = "exact")
tabz <- tibble(tabz[,4:6])
tabz <- bind_cols(tabz,nnx)
names(tabz)[4] <- "names"
#return(tabz)
#
tabz %>%
ggplot() +
aes(x = names, y = mean*100, fill = names) +
geom_bar(stat = "identity")  +
geom_errorbar(aes(ymin = lower * 100, ymax = upper * 100),
width = .2,
position = position_dodge(.9)) +
labs(title = tit,
subtitle = "",
y = tity,
caption = tit,
label = "stress1") +
theme_light() +
scale_fill_material() +
theme(
plot.title = element_text(size = 18, face = "bold"),
plot.subtitle = element_text(size = 12),
axis.title.x = element_text(size = 12),
axis.title.y = element_text(
size = 12,
angle = 90,
vjust = .5
),
axis.text.x = element_text(
size = 12 ,
angle = 0,
hjust = 0.5
),
axis.text.y = element_text(size = 12),
legend.position = "none"
)
}
graphconfx(zzx,rad.au.bon.moment,troubles.attentionnels, "Troubles.attentionnels & retour à domicile", titx = "Retour à domicile",tity = "% troubles.attentionnels")
tabcx <- function(dfx,
tri,
nomv,
titre = "Tableau comparatif",
lab = "tabcomp",
export = FALSE) {
# On supprime les données manquantes dans la variable de tri
dfx <- as_tibble(dfx)
dfx <- dfx %>%
dplyr::filter(!is.na({{tri}}))
var2 <- "+ age+profession, data = tt, family = binomial)"
#
tabx <- NULL
nlig <- 0
ligd <- NULL
trix <- enquo(tri)
vv <- quo_name(trix)
triz <- dfx[vv]
triz <- triz[[1]]
for (ll in seq_len(length(dfx))) {
varx <- dfx[, ll]
varx <- varx[[1]]
if (names(dfx)[ll] != vv) {
nom <- paste0("<b>", nomv[ll], "</b>")
var1 <-  paste0("glm(",vv,"~")
aa <- paste0(var1,names(dfx)[ll],var2)
ll <- eval(parse(text = aa))
dd <- logistic.display(ll, simplified = TRUE)
dd <- dd$table
if (is.numeric(varx)) {
# Variables numériques
lig <- lignumc(nom, varx, triz)
lig <- c(lig,beaup(dd[1,4]))
tabx <- rbind(tabx, lig)
nlig <- nlig + 1
} else {
# Variables factorielles
if(is.factor(varx)==FALSE){
varx <- as.factor(varx)
}
lig <- ligfcx(nom, varx, triz,beaup(dd[1,4]))
tabx <- rbind(tabx, lig)
llx <- length(levels(varx))
nlig <- nlig + 1 + llx
ligd <- c(ligd, seq(nlig - llx + 1, nlig))
}
# Export
if (export) {
nomcsv <- paste0(titre, "_export_comparatif.csv")
write.csv(tabx, nomcsv)
}
# Création tableaux
ltit <- c(" ", levels(triz), "p brut", "p ajusté")
tabf <-   kable(
tabx,
row.names = FALSE,
col.names = ltit,
caption = titre,
label = lab,
escape = FALSE
) %>%
kable_styling(
bootstrap_options = "striped",
full_width = FALSE,
position = "center"
)
if (!is.null(ligd)) {add_indent(tabf, ligd)}
#tabf %>%
# scroll_box(width = "100%", height = "850px")
}
######
ligfcx <- function(nom, varp, trip ,bdd) {
tabp <- table(varp, trip)
chip <- chisq.test(tabp, correct = TRUE)[[3]]
chip <- chisq.test(tabp, correct = FALSE)
if (min(chip$expected)<5){chip <- chisq.test(tabp, correct = TRUE)}
chip <- chip[[3]]
if (is.na(chip)){
chip <- fisher.test(tabp)[[1]]
}
chip <- beaup(chip)
ltri <- length(levels(trip))
lvar <- length(levels(varp))
tabg <- c(nom, rep(" ", ltri), chip,bdd)
#
ss <- colSums(tabp)
for (lig in 1:lvar) {
ligt <- levels(varp)[lig]
for (cas in 1:ltri) {
casx <- tabp[lig, cas]
casp <- round(100*casx/ss[cas],1)
cast <- paste0(casx,"/",ss[cas]," (",casp," %)" )
ligt <- c(ligt,cast)
}
ligt <- c(ligt, " ", " ")
tabg <- rbind(tabg, ligt)
}
return(tabg)
}
##
graphconfx <- function(fdx,varx, vars, tit = " ",titx= "", tity = "%") {
tabx <- fdx  %>%
summarise(tabx = table({{varx}},{{vars}}))
nnx <- fdx %>%
summarise(levels({{varx}}))
tabx <- as.matrix(tabx)
stabx <- rowSums(tabx)
tabo <- as.matrix(tabx)[,2]
tabz <- binom.confint(tabo,stabx, method = "exact")
tabz <- tibble(tabz[,4:6])
tabz <- bind_cols(tabz,nnx)
names(tabz)[4] <- "names"
#return(tabz)
#
tabz %>%
ggplot() +
aes(x = names, y = mean*100, fill = names) +
geom_bar(stat = "identity")  +
geom_errorbar(aes(ymin = lower * 100, ymax = upper * 100),
width = .2,
position = position_dodge(.9)) +
labs(title = tit,
subtitle = "",
x = titx,
y = tity,
caption = tit,
label = "stress1") +
theme_light() +
scale_fill_material() +
theme(
plot.title = element_text(size = 18, face = "bold"),
plot.subtitle = element_text(size = 12),
axis.title.x = element_text(size = 12),
axis.title.y = element_text(
size = 12,
angle = 90,
vjust = .5
),
axis.text.x = element_text(
size = 12 ,
angle = 0,
hjust = 0.5
),
axis.text.y = element_text(size = 12),
legend.position = "none"
)
}
graphconfx(zzx,rad.au.bon.moment,troubles.attentionnels, "Troubles.attentionnels & retour à domicile", titx = "Retour à domicile",tity = "% troubles.attentionnels")
graphconfx(zzx,rad.au.bon.moment,besoin.voir.medecin, "Besoin de voir un médecin & retour à domicile", titx = "Retour à domicile",tity = "% besoin de voir un médecin")
tabz
tabx
names(tt)
btitre
graphconfx(zzx,rad.au.bon.moment, entourage.au.domicile, "entourage au domicile & retour à domicile", titx = "Retour à domicile",tity = "% entourage au domicile")
names(tt)
graphconfx(zzx,rad.au.bon.moment, apprehension.sorties, "Appréhension sorties & retour à domicile", titx = "Retour à domicile",tity = "% appréhension sorties")
graphconfx(zzx,rad.au.bon.moment, apprehension.reprise.travail, "Appréhension reprise travail & retour à domicile", titx = "Retour à domicile",tity = "% appréhension reprise travail")
source("~/actif/novopsycovid/test.R")
source("~/actif/novopsycovid/graphconf.R")
