setwd("D:/mooc R statistique")
hop_sa <-read.csv2("D:/mooc R statistique/DATA/satisfaction_hopital.csv")
hop_sa$recommander.b <-ifelse(hop_sa$recommander<2,0,1)
table(hop_sa$recommander.b,hop_sa$sexe,deparse.level=2,useNA="always")
## hop_sa$sexe
## hop_sa$recommander.b 0 1 <NA>
## 0 73 63 0
## 1 139 130 0
## <NA> 56 73 0
tab <-table(hop_sa$recommander.b,hop_sa$sexe,deparse.level=2)
prop.table(tab,2)
## hop_sa$sexe
## hop_sa$recommander.b 0 1
## 0 0.3443 0.3264
## 1 0.6557 0.6736
chisq.test(hop_sa$recommander.b,hop_sa$sexe,correct=FALSE)
##
## Pearson's Chi-squared test
##
## data: hop_sa$recommander.b and hop_sa$sexe
## X-squared = 0.1454, df = 1, p-value = 0.703
hist(hop_sa$score.relation)
qqnorm(hop_sa$score.relation);qqline(hop_sa$score.relation)
by(hop_sa$score.relation,hop_sa$sexe,sd,na.rm=TRUE)
## hop_sa$sexe: 0
## [1] 4.552
## --------------------------------------------------------
## hop_sa$sexe: 1
## [1] 4.698
t.test(hop_sa$score.relation~hop_sa$sexe,var.equal=TRUE)
##
## Two Sample t-test
##
## data: hop_sa$score.relation by hop_sa$sexe
## t = 1.117, df = 347, p-value = 0.2649
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.4212 1.5275
## sample estimates:
## mean in group 0 mean in group 1
## 35.48 34.93
hist(hop_sa$age)
##Au vu de l’histogramme des âges qui en cloche la variable suit une loi normale
cor.test(hop_sa$score.relation,hop_sa$age)
##
## Pearson's product-moment correlation
##
## data: hop_sa$score.relation and hop_sa$age
## t = 1.796, df = 347, p-value = 0.07336
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.009102 0.198945
## sample estimates:
## cor
## 0.09597