This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2
## 1st Qu.:12.0 1st Qu.: 26
## Median :15.0 Median : 36
## Mean :15.4 Mean : 43
## 3rd Qu.:19.0 3rd Qu.: 56
## Max. :25.0 Max. :120
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
library(compareGroups)
## Loading required package: Hmisc
## Loading required package: grid
## Loading required package: lattice
## Loading required package: survival
## Loading required package: splines
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
##
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
##
## Loading required package: xtable
##
## Attaching package: 'xtable'
##
## The following objects are masked from 'package:Hmisc':
##
## label, label<-
##
## Loading required package: gdata
## gdata: Unable to locate valid perl interpreter
## gdata:
## gdata: read.xls() will be unable to read Excel XLS and XLSX files
## gdata: unless the 'perl=' argument is used to specify the location
## gdata: of a valid perl intrpreter.
## gdata:
## gdata: (To avoid display of this message in the future, please
## gdata: ensure perl is installed and available on the executable
## gdata: search path.)
## gdata: Unable to load perl libaries needed by read.xls()
## gdata: to support 'XLX' (Excel 97-2004) files.
##
## gdata: Unable to load perl libaries needed by read.xls()
## gdata: to support 'XLSX' (Excel 2007+) files.
##
## gdata: Run the function 'installXLSXsupport()'
## gdata: to automatically download and install the perl
## gdata: libaries needed to support Excel XLS and XLSX formats.
##
## Attaching package: 'gdata'
##
## The following object is masked from 'package:Hmisc':
##
## combine
##
## The following object is masked from 'package:stats':
##
## nobs
##
## The following object is masked from 'package:utils':
##
## object.size
##
## Loading required package: SNPassoc
## Loading required package: haplo.stats
## Loading required package: mvtnorm
## Loading required package: parallel
data(predimed)
predimed$tmain <- with(predimed, Surv(toevent, event == "Yes"))
label(predimed$tmain) <- "AMI, stroke, or CV Death"
res=compareGroups(group ~ . - toevent - event, data = predimed)
res
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method
## 1 Sex 6324 <0.001** categorical
## 2 Age 6324 0.003** continuous normal
## 3 Smoking 6324 0.444 categorical
## 4 Body mass index 6324 <0.001** continuous normal
## 5 Waist circumference 6324 0.045** continuous normal
## 6 Waist-to-height ratio 6324 <0.001** continuous normal
## 7 Hypertension 6324 0.249 categorical
## 8 Type-2 diabetes 6324 0.017** categorical
## 9 Dyslipidemia 6324 0.423 categorical
## 10 Family history of premature CHD 6324 0.581 categorical
## 11 Hormone-replacement therapy 5661 0.850 categorical
## 12 MeDiet Adherence score 6324 <0.001** continuous normal
## 13 AMI, stroke, or CV Death 6324 0.011** Surv [Tmax=4.79]
## selection
## 1 ALL
## 2 ALL
## 3 ALL
## 4 ALL
## 5 ALL
## 6 ALL
## 7 ALL
## 8 ALL
## 9 ALL
## 10 ALL
## 11 ALL
## 12 ALL
## 13 ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
createTable(res)
##
## --------Summary descriptives table by 'Intervention group'---------
##
## ____________________________________________________________________________________
## Control MedDiet + Nuts MedDiet + VOO p.overall
## N=2042 N=2100 N=2182
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Sex: <0.001
## Male 812 (39.8%) 968 (46.1%) 899 (41.2%)
## Female 1230 (60.2%) 1132 (53.9%) 1283 (58.8%)
## Age 67.3 (6.28) 66.7 (6.02) 67.0 (6.21) 0.003
## Smoking: 0.444
## Never 1282 (62.8%) 1259 (60.0%) 1351 (61.9%)
## Current 270 (13.2%) 296 (14.1%) 292 (13.4%)
## Former 490 (24.0%) 545 (26.0%) 539 (24.7%)
## Body mass index 30.3 (3.96) 29.7 (3.77) 29.9 (3.71) <0.001
## Waist circumference 101 (10.8) 100 (10.6) 100 (10.4) 0.045
## Waist-to-height ratio 0.63 (0.07) 0.62 (0.06) 0.63 (0.06) <0.001
## Hypertension: 0.249
## No 331 (16.2%) 362 (17.2%) 396 (18.1%)
## Yes 1711 (83.8%) 1738 (82.8%) 1786 (81.9%)
## Type-2 diabetes: 0.017
## No 1072 (52.5%) 1150 (54.8%) 1100 (50.4%)
## Yes 970 (47.5%) 950 (45.2%) 1082 (49.6%)
## Dyslipidemia: 0.423
## No 563 (27.6%) 561 (26.7%) 622 (28.5%)
## Yes 1479 (72.4%) 1539 (73.3%) 1560 (71.5%)
## Family history of premature CHD: 0.581
## No 1580 (77.4%) 1640 (78.1%) 1675 (76.8%)
## Yes 462 (22.6%) 460 (21.9%) 507 (23.2%)
## Hormone-replacement therapy: 0.850
## No 1811 (98.3%) 1835 (98.4%) 1918 (98.2%)
## Yes 31 (1.68%) 30 (1.61%) 36 (1.84%)
## MeDiet Adherence score 8.44 (1.94) 8.81 (1.90) 8.77 (1.97) <0.001
## AMI, stroke, or CV Death 5.80% 3.58% 3.76% 0.011
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
compareGroups(group ~ . -toevent -event ,data=predimed)
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method
## 1 Sex 6324 <0.001** categorical
## 2 Age 6324 0.003** continuous normal
## 3 Smoking 6324 0.444 categorical
## 4 Body mass index 6324 <0.001** continuous normal
## 5 Waist circumference 6324 0.045** continuous normal
## 6 Waist-to-height ratio 6324 <0.001** continuous normal
## 7 Hypertension 6324 0.249 categorical
## 8 Type-2 diabetes 6324 0.017** categorical
## 9 Dyslipidemia 6324 0.423 categorical
## 10 Family history of premature CHD 6324 0.581 categorical
## 11 Hormone-replacement therapy 5661 0.850 categorical
## 12 MeDiet Adherence score 6324 <0.001** continuous normal
## 13 AMI, stroke, or CV Death 6324 0.011** Surv [Tmax=4.79]
## selection
## 1 ALL
## 2 ALL
## 3 ALL
## 4 ALL
## 5 ALL
## 6 ALL
## 7 ALL
## 8 ALL
## 9 ALL
## 10 ALL
## 11 ALL
## 12 ALL
## 13 ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
res=compareGroups(group ~ age + sex + smoke + waist + hormo ,data=predimed)
res
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Age 6324 0.003** continuous normal ALL
## 2 Sex 6324 <0.001** categorical ALL
## 3 Smoking 6324 0.444 categorical ALL
## 4 Waist circumference 6324 0.045** continuous normal ALL
## 5 Hormone-replacement therapy 5661 0.850 categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group ~ age + sex + smoke + waist + hormo ,data=predimed,
subset=sex=="Female")
## Warning: Some levels of 'sex' are removed since no observation in that/those levels
## Warning: 표준편차가 0입니다
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method
## 1 Age 3645 0.056* continuous normal
## 2 Sex 3645 . categorical
## 3 Smoking 3645 0.907 categorical
## 4 Waist circumference 3645 0.016** continuous normal
## 5 Hormone-replacement therapy 3459 0.898 categorical
## selection
## 1 sex == "Female"
## 2 sex == "Female"
## 3 sex == "Female"
## 4 sex == "Female"
## 5 sex == "Female"
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group ~ age + smoke + waist + hormo, data=predimed,
selec = list(waist= !is.na(hormo)), subset = sex=="Female")
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method
## 1 Age 3645 0.056* continuous normal
## 2 Smoking 3645 0.907 categorical
## 3 Waist circumference 3459 0.007** continuous normal
## 4 Hormone-replacement therapy 3459 0.898 categorical
## selection
## 1 sex == "Female"
## 2 sex == "Female"
## 3 (sex == "Female") & (!is.na(hormo))
## 4 sex == "Female"
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group ~ age + sex + bmi + bmi +bmi+ waist + hormo, data=predimed,
selec = list(bmi.1=!is.na(hormo),bmi.2=sex=="Female"))
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method
## 1 Age 6324 0.003** continuous normal
## 2 Sex 6324 <0.001** categorical
## 3 Body mass index 6324 <0.001** continuous normal
## 4 Body mass index 5661 <0.001** continuous normal
## 5 Body mass index 3645 0.002** continuous normal
## 6 Waist circumference 6324 0.045** continuous normal
## 7 Hormone-replacement therapy 5661 0.850 categorical
## selection
## 1 ALL
## 2 ALL
## 3 ALL
## 4 !is.na(hormo)
## 5 sex == "Female"
## 6 ALL
## 7 ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group~age+smoke+waist+hormo,data=predimed, method=c(waist=2))
## Warning: Cannot compute exact p-value with ties
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Age 6324 0.003** continuous normal ALL
## 2 Smoking 6324 0.444 categorical ALL
## 3 Waist circumference 6324 0.085* continuous non-normal ALL
## 4 Hormone-replacement therapy 5661 0.850 categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group~age+smoke+waist+hormo,data=predimed,
method=c(waist=NA),alpha=0.01)
## Warning: Cannot compute exact p-value with ties
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Age 6324 0.003** continuous normal ALL
## 2 Smoking 6324 0.444 categorical ALL
## 3 Waist circumference 6324 0.085* continuous non-normal ALL
## 4 Hormone-replacement therapy 5661 0.850 categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
library(car)
cuts<-"lo:55=1; 56:60=2; 61:65=3; 66:70=4; 71:75=5; 76:80=6; 81:hi=7"
library(car)
predimed$age7gr<-car::recode(predimed$age, cuts)
compareGroups(group ~ age7gr, data=predimed, method = c(age7gr=NA))
## Warning: Cannot compute exact p-value with ties
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Age 6324 0.007** continuous non-normal ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group ~ age7gr, data=predimed, method = c(age7gr=NA), min.dis=8)
## Warning: variable 'age7gr' converted to factor since few different values
## contained
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Age 6324 0.009** categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(age7gr ~ sex+bmi+waist, data=predimed,max.ylev=7)
##
##
## -------- Summary of results by groups of 'Age'---------
##
##
## var N p.value method selection
## 1 Sex 6324 <0.001** categorical ALL
## 2 Body mass index 6324 0.021** continuous normal ALL
## 3 Waist circumference 6324 0.034** continuous normal ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
compareGroups(group ~ sex + age7gr, method= (age7gr=3), data=predimed, max.xlev=5)
## Warning: Variables 'age7gr' have been removed since some errors occurred
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Sex 6324 <0.001** categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
resu1<-compareGroups(group ~ age + waist, data=predimed, method = c(waist=2))
## Warning: Cannot compute exact p-value with ties
createTable(resu1)
##
## --------Summary descriptives table by 'Intervention group'---------
##
## __________________________________________________________________________
## Control MedDiet + Nuts MedDiet + VOO p.overall
## N=2042 N=2100 N=2182
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 67.3 (6.28) 66.7 (6.02) 67.0 (6.21) 0.003
## Waist circumference 101 [94.0;108] 100 [93.0;107] 100 [93.0;107] 0.085
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
resu2<-compareGroups(group ~ age + smoke + waist + hormo, data=predimed,
method = c(waist=2), Q1=0.025, Q3=0.975)
## Warning: Cannot compute exact p-value with ties
createTable(resu2)
##
## --------Summary descriptives table by 'Intervention group'---------
##
## ___________________________________________________________________________________
## Control MedDiet + Nuts MedDiet + VOO p.overall
## N=2042 N=2100 N=2182
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 67.3 (6.28) 66.7 (6.02) 67.0 (6.21) 0.003
## Smoking: 0.444
## Never 1282 (62.8%) 1259 (60.0%) 1351 (61.9%)
## Current 270 (13.2%) 296 (14.1%) 292 (13.4%)
## Former 490 (24.0%) 545 (26.0%) 539 (24.7%)
## Waist circumference 101 [80.0;123] 100 [80.0;121] 100 [80.0;121] 0.085
## Hormone-replacement therapy: 0.850
## No 1811 (98.3%) 1835 (98.4%) 1918 (98.2%)
## Yes 31 (1.68%) 30 (1.61%) 36 (1.84%)
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
resu3=compareGroups(group ~ age + smoke + waist + hormo, data=predimed,
method = c(waist=2), Q1=0, Q3=1)
## Warning: Cannot compute exact p-value with ties
createTable(resu3)
##
## --------Summary descriptives table by 'Intervention group'---------
##
## ___________________________________________________________________________________
## Control MedDiet + Nuts MedDiet + VOO p.overall
## N=2042 N=2100 N=2182
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 67.3 (6.28) 66.7 (6.02) 67.0 (6.21) 0.003
## Smoking: 0.444
## Never 1282 (62.8%) 1259 (60.0%) 1351 (61.9%)
## Current 270 (13.2%) 296 (14.1%) 292 (13.4%)
## Former 490 (24.0%) 545 (26.0%) 539 (24.7%)
## Waist circumference 101 [58.0;177] 100 [61.0;150] 100 [50.0;176] 0.085
## Hormone-replacement therapy: 0.850
## No 1811 (98.3%) 1835 (98.4%) 1918 (98.2%)
## Yes 31 (1.68%) 30 (1.61%) 36 (1.84%)
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
res<-compareGroups(group ~ age + sex + smoke + waist + hormo, method =c(waist=2), data=predimed)
## Warning: Cannot compute exact p-value with ties
summary(res[c(1,2,4)])
## Warning: Cannot compute exact p-value with ties
##
## --- Descriptives of each row-variable by groups of 'Intervention group' ---
##
## -------------------
## row-variable: Age
##
## N mean sd p.overall p.trend
## [ALL] 6324 67.01 6.175
## Control 2042 67.34 6.28 0.002666 0.1012
## MedDiet + Nuts 2100 66.68 6.016
## MedDiet + VOO 2182 67.02 6.213
## p.Control vs MedDiet + Nuts p.Control vs MedDiet + VOO
## [ALL]
## Control 0.001672 0.206
## MedDiet + Nuts
## MedDiet + VOO
## p.MedDiet + Nuts vs MedDiet + VOO
## [ALL]
## Control 0.1727
## MedDiet + Nuts
## MedDiet + VOO
##
## -------------------
## row-variable: Sex
##
## Male Female Male (row%) Female (row%) p.overall p.trend
## [ALL] 2679 3645 42.36 57.64
## Control 812 1230 39.76 60.24 8.1e-05 0.3884
## MedDiet + Nuts 968 1132 46.1 53.9
## MedDiet + VOO 899 1283 41.2 58.8
## p.Control vs MedDiet + Nuts p.Control vs MedDiet + VOO
## [ALL]
## Control 0.000133 0.3583
## MedDiet + Nuts
## MedDiet + VOO
## p.MedDiet + Nuts vs MedDiet + VOO
## [ALL]
## Control 0.002076
## MedDiet + Nuts
## MedDiet + VOO
##
## -------------------
## row-variable: Waist circumference
##
## N med Q1 Q3 p.overall p.trend
## [ALL] 6324 100 93 107
## Control 2042 101 94 108 0.0846 0.03956
## MedDiet + Nuts 2100 100 93 107
## MedDiet + VOO 2182 100 93 107
## p.Control vs MedDiet + Nuts p.Control vs MedDiet + VOO
## [ALL]
## Control 0.1258 0.1106
## MedDiet + Nuts
## MedDiet + VOO
## p.MedDiet + Nuts vs MedDiet + VOO
## [ALL]
## Control 0.7435
## MedDiet + Nuts
## MedDiet + VOO
library(plot2groups)
plot(res[c(1,2)],bivar=TRUE)
## Warning: variables waist specified in 'method' not found
plot(res[c(1,2)],bivar=TRUE)
## Warning: variables waist specified in 'method' not found
res<-compareGroups(group ~ age + sex + smoke + waist + hormo, data=predimed)
res
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method selection
## 1 Age 6324 0.003** continuous normal ALL
## 2 Sex 6324 <0.001** categorical ALL
## 3 Smoking 6324 0.444 categorical ALL
## 4 Waist circumference 6324 0.045** continuous normal ALL
## 5 Hormone-replacement therapy 5661 0.850 categorical ALL
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
res<-update(res, . ~. -sex + bmi + toevent, subset = sex=="Female", method = c(waist=2, toevent=2), selec = list(bmi=!is.na(hormo)))
## Warning: Cannot compute exact p-value with ties
## Warning: Cannot compute exact p-value with ties
res
##
##
## -------- Summary of results by groups of 'Intervention group'---------
##
##
## var N p.value method
## 1 Age 3645 0.056* continuous normal
## 2 Smoking 3645 0.907 categorical
## 3 Waist circumference 3645 0.037** continuous non-normal
## 4 Hormone-replacement therapy 3459 0.898 categorical
## 5 Body mass index 3459 0.002** continuous normal
## 6 follow-up to main event (years) 3645 <0.001** continuous non-normal
## selection
## 1 sex == "Female"
## 2 sex == "Female"
## 3 sex == "Female"
## 4 sex == "Female"
## 5 (sex == "Female") & (!is.na(hormo))
## 6 sex == "Female"
## -----
## Signif. codes: 0 '**' 0.05 '*' 0.1 ' ' 1
res1=compareGroups(htn~age+sex+bmi+smoke,data=predimed,ref=1)
createTable(res1,show.ratio=TRUE)
##
## --------Summary descriptives table by 'Hypertension'---------
##
## ___________________________________________________________________________
## No Yes OR p.ratio p.overall
## N=1089 N=5235
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 65.9 (6.19) 67.2 (6.15) 1.04 [1.03;1.05] <0.001 <0.001
## Sex: <0.001
## Male 595 (54.6%) 2084 (39.8%) Ref. Ref.
## Female 494 (45.4%) 3151 (60.2%) 1.82 [1.60;2.08] 0.000
## Body mass index 28.9 (3.69) 30.2 (3.80) 1.10 [1.08;1.12] <0.001 <0.001
## Smoking: <0.001
## Never 536 (49.2%) 3356 (64.1%) Ref. Ref.
## Current 233 (21.4%) 625 (11.9%) 0.43 [0.36;0.51] 0.000
## Former 320 (29.4%) 1254 (24.0%) 0.63 [0.54;0.73] <0.001
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
res2=compareGroups(htn~age+sex+bmi+smoke,data=predimed, ref=c(smoke=1,sex=2))
createTable(res2,show.ratio=TRUE)
##
## --------Summary descriptives table by 'Hypertension'---------
##
## ___________________________________________________________________________
## No Yes OR p.ratio p.overall
## N=1089 N=5235
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 65.9 (6.19) 67.2 (6.15) 1.04 [1.03;1.05] <0.001 <0.001
## Sex: <0.001
## Male 595 (54.6%) 2084 (39.8%) 0.55 [0.48;0.63] 0.000
## Female 494 (45.4%) 3151 (60.2%) Ref. Ref.
## Body mass index 28.9 (3.69) 30.2 (3.80) 1.10 [1.08;1.12] <0.001 <0.001
## Smoking: <0.001
## Never 536 (49.2%) 3356 (64.1%) Ref. Ref.
## Current 233 (21.4%) 625 (11.9%) 0.43 [0.36;0.51] 0.000
## Former 320 (29.4%) 1254 (24.0%) 0.63 [0.54;0.73] <0.001
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
res<-compareGroups(htn~age+sex+bmi+hormo+hyperchol,data=predimed, ref.no="NO")
createTable(res,show.ratio=TRUE)
##
## --------Summary descriptives table by 'Hypertension'---------
##
## ________________________________________________________________________________________
## No Yes OR p.ratio p.overall
## N=1089 N=5235
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 65.9 (6.19) 67.2 (6.15) 1.04 [1.03;1.05] <0.001 <0.001
## Sex: <0.001
## Male 595 (54.6%) 2084 (39.8%) Ref. Ref.
## Female 494 (45.4%) 3151 (60.2%) 1.82 [1.60;2.08] 0.000
## Body mass index 28.9 (3.69) 30.2 (3.80) 1.10 [1.08;1.12] <0.001 <0.001
## Hormone-replacement therapy: 0.856
## No 928 (98.4%) 4636 (98.3%) Ref. Ref.
## Yes 15 (1.59%) 82 (1.74%) 1.08 [0.64;1.97] 0.773
## Dyslipidemia: <0.001
## No 409 (37.6%) 1337 (25.5%) Ref. Ref.
## Yes 680 (62.4%) 3898 (74.5%) 1.75 [1.53;2.01] <0.001
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
res<-compareGroups(htn~age+bmi, data=predimed)
createTable(res, show.ratio=TRUE)
##
## --------Summary descriptives table by 'Hypertension'---------
##
## __________________________________________________________________________
## No Yes OR p.ratio p.overall
## N=1089 N=5235
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 65.9 (6.19) 67.2 (6.15) 1.04 [1.03;1.05] <0.001 <0.001
## Body mass index 28.9 (3.69) 30.2 (3.80) 1.10 [1.08;1.12] <0.001 <0.001
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
res<-compareGroups(htn~age+bmi,data=predimed,fact.ratio=c(age=10,bmi=2))
createTable(res, show.ratio=TRUE)
##
## --------Summary descriptives table by 'Hypertension'---------
##
## __________________________________________________________________________
## No Yes OR p.ratio p.overall
## N=1089 N=5235
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 65.9 (6.19) 67.2 (6.15) 1.43 [1.28;1.59] <0.001 <0.001
## Body mass index 28.9 (3.69) 30.2 (3.80) 1.22 [1.17;1.26] <0.001 <0.001
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
res<-compareGroups(htn~age+sex+bmi+hyperchol, data=predimed, ref.y=2)
createTable(res,show.ratio=TRUE)
##
## --------Summary descriptives table by 'Hypertension'---------
##
## ___________________________________________________________________________
## No Yes OR p.ratio p.overall
## N=1089 N=5235
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
## Age 65.9 (6.19) 67.2 (6.15) 0.96 [0.98;0.95] <0.001 <0.001
## Sex: <0.001
## Male 595 (54.6%) 2084 (39.8%) Ref. Ref.
## Female 494 (45.4%) 3151 (60.2%) 0.55 [0.48;0.63] 0.000
## Body mass index 28.9 (3.69) 30.2 (3.80) 0.91 [0.92;0.89] <0.001 <0.001
## Dyslipidemia: <0.001
## No 409 (37.6%) 1337 (25.5%) Ref. Ref.
## Yes 680 (62.4%) 3898 (74.5%) 0.57 [0.50;0.65] <0.001
## <U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF>
plot(compareGroups(tmain~sex,data=predimed), bivar=TRUE)
plot(compareGroups(tmain~age,data=predimed), bivar=TRUE)