Easily retrieve summary data as R-objects (matrices and vectors).
getResults.Rd
This functions excratcs specific results (descriptives, p-values, Odds-Ratios / Hazard-Ratios, ...) from a compareGroups object as matrix or vectors.
Value
- what = "descr"
An array or matrix with as many columns as variables/categories and seven columns indicating all possible descriptive statistics (mean, sd, median, Q1, Q3, absolute and relative frequencies). When different groups are analysed, the 3rd dimension of the array corresponds to the groups. Otherwise, the result will be a matrix with no 3rd dimension.
- what = "p.overall"
A vector whose elevements are the p-value for each analysed variable.
- what = "p.trend"
A vector whose elevements are the p-trend for each analysed variable.
- what = "p.mul"
A matrix with pairwise p-values where rows correspond to the analysed variables and columns to each pair of groups.
- what = "ratio"
A matrix with as many rows as variables/categorieswith and 4 columns corresponding to the OR/HR, confidence interval and p-value.
Note
For descriptives, NA is placed for descriptives not appropiate for the variable. For example columns corresponding to frequencies for continuous variables will be NA.
Examples
require(compareGroups)
data(regicor)
res<-compareGroups(sex ~ . ,regicor,method=c(triglyc=2))
# retrieve descriptives
getResults(res)
#> , , [ALL]
#>
#> mean sd med
#> Individual id 1.215818e+09 1.339539e+09 NA
#> Recruitment year: 1995 NA NA NA
#> Recruitment year: 2000 NA NA NA
#> Recruitment year: 2005 NA NA NA
#> Age 5.473627e+01 1.104926e+01 NA
#> Smoking status: Never smoker NA NA NA
#> Smoking status: Current or former < 1y NA NA NA
#> Smoking status: Former >= 1y NA NA NA
#> Systolic blood pressure 1.311741e+02 2.030658e+01 NA
#> Diastolic blood pressure 7.965877e+01 1.054792e+01 NA
#> History of hypertension: Yes NA NA NA
#> History of hypertension: No NA NA NA
#> Hypertension treatment: No NA NA NA
#> Hypertension treatment: Yes NA NA NA
#> Total cholesterol 2.187577e+02 4.524609e+01 NA
#> HDL cholesterol 5.268910e+01 1.474849e+01 NA
#> Triglycerides NA NA 97
#> LDL cholesterol 1.432467e+02 3.969013e+01 NA
#> History of hyperchol.: Yes NA NA NA
#> History of hyperchol.: No NA NA NA
#> Cholesterol treatment: No NA NA NA
#> Cholesterol treatment: Yes NA NA NA
#> Height (cm) 1.629156e+02 9.216404e+00 NA
#> Weight (Kg) 7.343586e+01 1.367845e+01 NA
#> Body mass index 2.764126e+01 4.555700e+00 NA
#> Physical activity (Kcal/week) 3.988314e+02 3.881642e+02 NA
#> Physical component 4.961986e+01 9.009636e+00 NA
#> Mental component 4.798318e+01 1.098306e+01 NA
#> Cardiovascular event: No NA NA NA
#> Cardiovascular event: Yes NA NA NA
#> Days to cardiovascular event or end of follow-up 1.754668e+03 1.080625e+03 NA
#> Overall death: No NA NA NA
#> Overall death: Yes NA NA NA
#> Days to overall death or end of follow-up 1.721305e+03 1.051047e+03 NA
#> Q1 Q3 n prop inc
#> Individual id NA NA NA NA NA
#> Recruitment year: 1995 NA NA 431 0.18788143 NA
#> Recruitment year: 2000 NA NA 786 0.34263296 NA
#> Recruitment year: 2005 NA NA 1077 0.46948561 NA
#> Age NA NA NA NA NA
#> Smoking status: Never smoker NA NA 1201 0.53784147 NA
#> Smoking status: Current or former < 1y NA NA 593 0.26556202 NA
#> Smoking status: Former >= 1y NA NA 439 0.19659651 NA
#> Systolic blood pressure NA NA NA NA NA
#> Diastolic blood pressure NA NA NA NA NA
#> History of hypertension: Yes NA NA 723 0.31627297 NA
#> History of hypertension: No NA NA 1563 0.68372703 NA
#> Hypertension treatment: No NA NA 1823 0.80986228 NA
#> Hypertension treatment: Yes NA NA 428 0.19013772 NA
#> Total cholesterol NA NA NA NA NA
#> HDL cholesterol NA NA NA NA NA
#> Triglycerides 72 136 NA NA NA
#> LDL cholesterol NA NA NA NA NA
#> History of hyperchol.: Yes NA NA 709 0.31192257 NA
#> History of hyperchol.: No NA NA 1564 0.68807743 NA
#> Cholesterol treatment: No NA NA 2011 0.89816883 NA
#> Cholesterol treatment: Yes NA NA 228 0.10183117 NA
#> Height (cm) NA NA NA NA NA
#> Weight (Kg) NA NA NA NA NA
#> Body mass index NA NA NA NA NA
#> Physical activity (Kcal/week) NA NA NA NA NA
#> Physical component NA NA NA NA NA
#> Mental component NA NA NA NA NA
#> Cardiovascular event: No NA NA 2071 0.95746648 NA
#> Cardiovascular event: Yes NA NA 92 0.04253352 NA
#> Days to cardiovascular event or end of follow-up NA NA NA NA NA
#> Overall death: No NA NA 1975 0.91945996 NA
#> Overall death: Yes NA NA 173 0.08054004 NA
#> Days to overall death or end of follow-up NA NA NA NA NA
#> lower upper
#> Individual id 1.160973e+09 1.270662e+09
#> Recruitment year: 1995 1.720853e-01 2.044788e-01
#> Recruitment year: 2000 3.232053e-01 3.624633e-01
#> Recruitment year: 2005 4.488951e-01 4.901542e-01
#> Age 5.428388e+01 5.518866e+01
#> Smoking status: Never smoker 5.169004e-01 5.586831e-01
#> Smoking status: Current or former < 1y 2.473380e-01 2.844032e-01
#> Smoking status: Former >= 1y 1.802952e-01 2.136979e-01
#> Systolic blood pressure 1.303402e+02 1.320081e+02
#> Diastolic blood pressure 7.922558e+01 8.009196e+01
#> History of hypertension: Yes 2.972371e-01 3.357808e-01
#> History of hypertension: No 6.642192e-01 7.027629e-01
#> Hypertension treatment: No 7.930303e-01 8.258836e-01
#> Hypertension treatment: Yes 1.741164e-01 2.069697e-01
#> Total cholesterol 2.168629e+02 2.206524e+02
#> HDL cholesterol 5.207594e+01 5.330225e+01
#> Triglycerides 9.500000e+01 1.000000e+02
#> LDL cholesterol 1.415586e+02 1.449348e+02
#> History of hyperchol.: Yes 2.929097e-01 3.314214e-01
#> History of hyperchol.: No 6.685786e-01 7.070903e-01
#> Cholesterol treatment: No 8.848931e-01 9.103918e-01
#> Cholesterol treatment: Yes 8.960824e-02 1.151069e-01
#> Height (cm) 1.625354e+02 1.632959e+02
#> Weight (Kg) 7.287149e+01 7.400022e+01
#> Body mass index 2.745330e+01 2.782923e+01
#> Physical activity (Kcal/week) 3.826245e+02 4.150383e+02
#> Physical component 4.923000e+01 5.000972e+01
#> Mental component 4.750793e+01 4.845844e+01
#> Cardiovascular event: No 9.480894e-01 9.655767e-01
#> Cardiovascular event: Yes 3.442330e-02 5.191059e-02
#> Days to cardiovascular event or end of follow-up 1.709102e+03 1.800234e+03
#> Overall death: No 9.071378e-01 9.306225e-01
#> Overall death: Yes 6.937752e-02 9.286216e-02
#> Days to overall death or end of follow-up 1.676832e+03 1.765778e+03
#>
#> , , Male
#>
#> mean sd med
#> Individual id 1.249812e+09 1.347204e+09 NA
#> Recruitment year: 1995 NA NA NA
#> Recruitment year: 2000 NA NA NA
#> Recruitment year: 2005 NA NA NA
#> Age 5.478474e+01 1.108709e+01 NA
#> Smoking status: Never smoker NA NA NA
#> Smoking status: Current or former < 1y NA NA NA
#> Smoking status: Former >= 1y NA NA NA
#> Systolic blood pressure 1.340373e+02 1.894442e+01 NA
#> Diastolic blood pressure 8.165665e+01 1.019543e+01 NA
#> History of hypertension: Yes NA NA NA
#> History of hypertension: No NA NA NA
#> Hypertension treatment: No NA NA NA
#> Hypertension treatment: Yes NA NA NA
#> Total cholesterol 2.172795e+02 4.274327e+01 NA
#> HDL cholesterol 4.754918e+01 1.259985e+01 NA
#> Triglycerides NA NA 110
#> LDL cholesterol 1.447680e+02 3.854902e+01 NA
#> History of hyperchol.: Yes NA NA NA
#> History of hyperchol.: No NA NA NA
#> Cholesterol treatment: No NA NA NA
#> Cholesterol treatment: Yes NA NA NA
#> Height (cm) 1.692727e+02 7.340116e+00 NA
#> Weight (Kg) 7.971587e+01 1.191404e+01 NA
#> Body mass index 2.781147e+01 3.730815e+00 NA
#> Physical activity (Kcal/week) 4.066184e+02 4.248869e+02 NA
#> Physical component 5.104962e+01 8.010419e+00 NA
#> Mental component 5.035020e+01 9.906833e+00 NA
#> Cardiovascular event: No NA NA NA
#> Cardiovascular event: Yes NA NA NA
#> Days to cardiovascular event or end of follow-up 1.744434e+03 1.082418e+03 NA
#> Overall death: No NA NA NA
#> Overall death: Yes NA NA NA
#> Days to overall death or end of follow-up 1.677167e+03 1.029199e+03 NA
#> Q1 Q3 n prop inc
#> Individual id NA NA NA NA NA
#> Recruitment year: 1995 NA NA 206 0.18710263 NA
#> Recruitment year: 2000 NA NA 390 0.35422343 NA
#> Recruitment year: 2005 NA NA 505 0.45867393 NA
#> Age NA NA NA NA NA
#> Smoking status: Never smoker NA NA 301 0.28104575 NA
#> Smoking status: Current or former < 1y NA NA 410 0.38281979 NA
#> Smoking status: Former >= 1y NA NA 360 0.33613445 NA
#> Systolic blood pressure NA NA NA NA NA
#> Diastolic blood pressure NA NA NA NA NA
#> History of hypertension: Yes NA NA 341 0.31113139 NA
#> History of hypertension: No NA NA 755 0.68886861 NA
#> Hypertension treatment: No NA NA 889 0.82467532 NA
#> Hypertension treatment: Yes NA NA 189 0.17532468 NA
#> Total cholesterol NA NA NA NA NA
#> HDL cholesterol NA NA NA NA NA
#> Triglycerides 80 147 NA NA NA
#> LDL cholesterol NA NA NA NA NA
#> History of hyperchol.: Yes NA NA 353 0.32266910 NA
#> History of hyperchol.: No NA NA 741 0.67733090 NA
#> Cholesterol treatment: No NA NA 962 0.89405204 NA
#> Cholesterol treatment: Yes NA NA 114 0.10594796 NA
#> Height (cm) NA NA NA NA NA
#> Weight (Kg) NA NA NA NA NA
#> Body mass index NA NA NA NA NA
#> Physical activity (Kcal/week) NA NA NA NA NA
#> Physical component NA NA NA NA NA
#> Mental component NA NA NA NA NA
#> Cardiovascular event: No NA NA 996 0.95585413 NA
#> Cardiovascular event: Yes NA NA 46 0.04414587 NA
#> Days to cardiovascular event or end of follow-up NA NA NA NA NA
#> Overall death: No NA NA 943 0.91553398 NA
#> Overall death: Yes NA NA 87 0.08446602 NA
#> Days to overall death or end of follow-up NA NA NA NA NA
#> lower upper
#> Individual id 1.170147e+09 1.329477e+09
#> Recruitment year: 1995 1.644727e-01 2.114180e-01
#> Recruitment year: 2000 3.259398e-01 3.832887e-01
#> Recruitment year: 2005 4.289308e-01 4.886385e-01
#> Age 5.412912e+01 5.544036e+01
#> Smoking status: Never smoker 2.542900e-01 3.090103e-01
#> Smoking status: Current or former < 1y 3.535980e-01 4.126874e-01
#> Smoking status: Former >= 1y 3.078595e-01 3.653131e-01
#> Systolic blood pressure 1.329156e+02 1.351591e+02
#> Diastolic blood pressure 8.105293e+01 8.226036e+01
#> History of hypertension: Yes 2.838046e-01 3.394762e-01
#> History of hypertension: No 6.605238e-01 7.161954e-01
#> Hypertension treatment: No 8.006357e-01 8.469272e-01
#> Hypertension treatment: Yes 1.530728e-01 1.993643e-01
#> Total cholesterol 2.146961e+02 2.198629e+02
#> HDL cholesterol 4.679513e+01 4.830323e+01
#> Triglycerides 1.060000e+02 1.140000e+02
#> LDL cholesterol 1.423878e+02 1.471482e+02
#> History of hyperchol.: Yes 2.950178e-01 3.512778e-01
#> History of hyperchol.: No 6.487222e-01 7.049822e-01
#> Cholesterol treatment: No 8.741082e-01 9.118089e-01
#> Cholesterol treatment: Yes 8.819106e-02 1.258918e-01
#> Height (cm) 1.688364e+02 1.697089e+02
#> Weight (Kg) 7.900780e+01 8.042394e+01
#> Body mass index 2.758974e+01 2.803320e+01
#> Physical activity (Kcal/week) 3.810110e+02 4.322258e+02
#> Physical component 5.055304e+01 5.154621e+01
#> Mental component 4.973605e+01 5.096435e+01
#> Cardiovascular event: No 9.415520e-01 9.675014e-01
#> Cardiovascular event: Yes 3.249863e-02 5.844796e-02
#> Days to cardiovascular event or end of follow-up 1.678636e+03 1.810233e+03
#> Overall death: No 8.968538e-01 9.317952e-01
#> Overall death: Yes 6.820481e-02 1.031462e-01
#> Days to overall death or end of follow-up 1.614239e+03 1.740094e+03
#>
#> , , Female
#>
#> mean sd med
#> Individual id 1.184445e+09 1.332220e+09 NA
#> Recruitment year: 1995 NA NA NA
#> Recruitment year: 2000 NA NA NA
#> Recruitment year: 2005 NA NA NA
#> Age 5.469153e+01 1.101869e+01 NA
#> Smoking status: Never smoker NA NA NA
#> Smoking status: Current or former < 1y NA NA NA
#> Smoking status: Former >= 1y NA NA NA
#> Systolic blood pressure 1.285144e+02 2.115815e+01 NA
#> Diastolic blood pressure 7.780288e+01 1.053501e+01 NA
#> History of hypertension: Yes NA NA NA
#> History of hypertension: No NA NA NA
#> Hypertension treatment: No NA NA NA
#> Hypertension treatment: Yes NA NA NA
#> Total cholesterol 2.201255e+02 4.742239e+01 NA
#> HDL cholesterol 5.749380e+01 1.499370e+01 NA
#> Triglycerides NA NA 87.5
#> LDL cholesterol 1.418699e+02 4.066348e+01 NA
#> History of hyperchol.: Yes NA NA NA
#> History of hyperchol.: No NA NA NA
#> Cholesterol treatment: No NA NA NA
#> Cholesterol treatment: Yes NA NA NA
#> Height (cm) 1.569882e+02 6.410992e+00 NA
#> Weight (Kg) 6.758024e+01 1.257931e+01 NA
#> Body mass index 2.748256e+01 5.205095e+00 NA
#> Physical activity (Kcal/week) 3.916288e+02 3.508277e+02 NA
#> Physical component 4.825805e+01 9.676943e+00 NA
#> Mental component 4.572867e+01 1.147720e+01 NA
#> Cardiovascular event: No NA NA NA
#> Cardiovascular event: Yes NA NA NA
#> Days to cardiovascular event or end of follow-up 1.764180e+03 1.079351e+03 NA
#> Overall death: No NA NA NA
#> Overall death: Yes NA NA NA
#> Days to overall death or end of follow-up 1.761969e+03 1.069629e+03 NA
#> Q1 Q3 n prop inc
#> Individual id NA NA NA NA NA
#> Recruitment year: 1995 NA NA 225 0.18860017 NA
#> Recruitment year: 2000 NA NA 396 0.33193630 NA
#> Recruitment year: 2005 NA NA 572 0.47946354 NA
#> Age NA NA NA NA NA
#> Smoking status: Never smoker NA NA 900 0.77452668 NA
#> Smoking status: Current or former < 1y NA NA 183 0.15748709 NA
#> Smoking status: Former >= 1y NA NA 79 0.06798623 NA
#> Systolic blood pressure NA NA NA NA NA
#> Diastolic blood pressure NA NA NA NA NA
#> History of hypertension: Yes NA NA 382 0.32100840 NA
#> History of hypertension: No NA NA 808 0.67899160 NA
#> Hypertension treatment: No NA NA 934 0.79624893 NA
#> Hypertension treatment: Yes NA NA 239 0.20375107 NA
#> Total cholesterol NA NA NA NA NA
#> HDL cholesterol NA NA NA NA NA
#> Triglycerides 66 120 NA NA NA
#> LDL cholesterol NA NA NA NA NA
#> History of hyperchol.: Yes NA NA 356 0.30195081 NA
#> History of hyperchol.: No NA NA 823 0.69804919 NA
#> Cholesterol treatment: No NA NA 1049 0.90197764 NA
#> Cholesterol treatment: Yes NA NA 114 0.09802236 NA
#> Height (cm) NA NA NA NA NA
#> Weight (Kg) NA NA NA NA NA
#> Body mass index NA NA NA NA NA
#> Physical activity (Kcal/week) NA NA NA NA NA
#> Physical component NA NA NA NA NA
#> Mental component NA NA NA NA NA
#> Cardiovascular event: No NA NA 1075 0.95896521 NA
#> Cardiovascular event: Yes NA NA 46 0.04103479 NA
#> Days to cardiovascular event or end of follow-up NA NA NA NA NA
#> Overall death: No NA NA 1032 0.92307692 NA
#> Overall death: Yes NA NA 86 0.07692308 NA
#> Days to overall death or end of follow-up NA NA NA NA NA
#> lower upper
#> Individual id 1.108771e+09 1.260118e+09
#> Recruitment year: 1995 1.667721e-01 2.119748e-01
#> Recruitment year: 2000 3.052374e-01 3.594665e-01
#> Recruitment year: 2005 4.507763e-01 5.082522e-01
#> Age 5.406564e+01 5.531743e+01
#> Smoking status: Never smoker 7.493901e-01 7.982653e-01
#> Smoking status: Current or former < 1y 1.370006e-01 1.797237e-01
#> Smoking status: Former >= 1y 5.419142e-02 8.401374e-02
#> Systolic blood pressure 1.273070e+02 1.297218e+02
#> Diastolic blood pressure 7.720168e+01 7.840408e+01
#> History of hypertension: Yes 2.945324e-01 3.483722e-01
#> History of hypertension: No 6.516278e-01 7.054676e-01
#> Hypertension treatment: No 7.720427e-01 8.189596e-01
#> Hypertension treatment: Yes 1.810404e-01 2.279573e-01
#> Total cholesterol 2.173686e+02 2.228825e+02
#> HDL cholesterol 5.662631e+01 5.836129e+01
#> Triglycerides 8.500000e+01 9.100000e+01
#> LDL cholesterol 1.394816e+02 1.442582e+02
#> History of hyperchol.: Yes 2.758418e-01 3.290517e-01
#> History of hyperchol.: No 6.709483e-01 7.241582e-01
#> Cholesterol treatment: No 8.834281e-01 9.184632e-01
#> Cholesterol treatment: Yes 8.153681e-02 1.165719e-01
#> Height (cm) 1.566203e+02 1.573561e+02
#> Weight (Kg) 6.685839e+01 6.830209e+01
#> Body mass index 2.718387e+01 2.778125e+01
#> Physical activity (Kcal/week) 3.712954e+02 4.119621e+02
#> Physical component 4.767262e+01 4.884349e+01
#> Mental component 4.503432e+01 4.642301e+01
#> Cardiovascular event: No 9.456423e-01 9.698035e-01
#> Cardiovascular event: Yes 3.019651e-02 5.435771e-02
#> Days to cardiovascular event or end of follow-up 1.700928e+03 1.827433e+03
#> Overall death: No 9.058705e-01 9.380139e-01
#> Overall death: Yes 6.198605e-02 9.412949e-02
#> Days to overall death or end of follow-up 1.699202e+03 1.824736e+03
#>
# retrieve OR and their corresponding p-values
getResults(res,what="ratio")
#> OR OR.lower
#> Individual id 1.00000000 1.00000000
#> Recruitment year: 2000 0.92973770 0.73464737
#> Recruitment year: 2005 1.03703804 0.82887136
#> Age 0.99923650 0.99185476
#> Smoking status: Current or former < 1y 0.14954071 0.12004545
#> Smoking status: Former >= 1y 0.07363818 0.05554227
#> Systolic blood pressure 0.98645343 0.98235797
#> Diastolic blood pressure 0.96469756 0.95679273
#> History of hypertension: No 0.95538389 0.80058784
#> Hypertension treatment: Yes 1.20334625 0.97404308
#> Total cholesterol 1.00139478 0.99953684
#> HDL cholesterol 1.05403395 1.04680956
#> Triglycerides 0.99312696 0.99161403
#> LDL cholesterol 0.99815969 0.99601738
#> History of hyperchol.: No 1.10125105 0.92201065
#> Cholesterol treatment: Yes 0.91711102 0.69691476
#> Height (cm) 0.76924517 0.75309866
#> Weight (Kg) 0.92237352 0.91477961
#> Body mass index 0.98425663 0.96655383
#> Physical activity (Kcal/week) 0.99990038 0.99968462
#> Physical component 0.96492588 0.95520350
#> Mental component 0.96013615 0.95193173
#> Cardiovascular event: Yes 0.92652448 0.60869018
#> Days to cardiovascular event or end of follow-up 1.00001692 0.99993885
#> Overall death: Yes 0.90334143 0.66129680
#> Days to overall death or end of follow-up 1.00007689 0.99999620
#> OR.upper pval
#> Individual id 1.00000000 2.428983e-01
#> Recruitment year: 2000 1.17621611 5.438095e-01
#> Recruitment year: 2005 1.29711990 7.501763e-01
#> Age 1.00667317 8.399987e-01
#> Smoking status: Current or former < 1y 0.18560560 0.000000e+00
#> Smoking status: Former >= 1y 0.09660496 0.000000e+00
#> Systolic blood pressure 0.99056597 1.314480e-10
#> Diastolic blood pressure 0.97266771 1.114680e-17
#> History of hypertension: No 1.13983473 6.124146e-01
#> Hypertension treatment: Yes 1.48827608 8.619969e-02
#> Total cholesterol 1.00325617 1.412835e-01
#> HDL cholesterol 1.06130820 7.706286e-51
#> Triglycerides 0.99464220 7.552867e-19
#> LDL cholesterol 1.00030660 9.289571e-02
#> History of hyperchol.: No 1.31537018 2.872368e-01
#> Cholesterol treatment: Yes 1.20689119 5.363264e-01
#> Height (cm) 0.78573786 8.696034e-130
#> Weight (Kg) 0.93003046 8.413354e-82
#> Body mass index 1.00228367 8.659591e-02
#> Physical activity (Kcal/week) 1.00011620 3.655988e-01
#> Physical component 0.97474721 4.840485e-12
#> Mental component 0.96841128 1.531181e-20
#> Cardiovascular event: Yes 1.41038249 7.210919e-01
#> Days to cardiovascular event or end of follow-up 1.00009500 6.710408e-01
#> Overall death: Yes 1.23369266 5.220728e-01
#> Days to overall death or end of follow-up 1.00015759 6.180690e-02