-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.Rmd
150 lines (83 loc) · 4.22 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
md_document:
variant: markdown_github
title: "compareGroups"
output: md_document
always_allow_html: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE, comment="")
library(knitr)
```
# **compareGroups** <img src="man/figures/logo.png" align="right" width="120px"/>
**_package to create descriptive tables_**
[![CRAN version](https://www.r-pkg.org/badges/version/compareGroups)](https://cran.r-project.org/package=compareGroups) ![](https://cranlogs.r-pkg.org/badges/grand-total/compareGroups) ![](https://cranlogs.r-pkg.org/badges/last-month/compareGroups)
## Overview
**compareGroups** is an R package available on CRAN which performs descriptive tables displaying means, standard deviation, quantiles or frequencies of several variables. Also, p-value to test equality between groups is computed using the appropiate test. <br>
With a very simple code, nice, compact and ready-to-publish descriptives table are displayed on R console. They can also be exported to different formats, such as Word, Excel, PDF or inserted in a R-Sweave or R-markdown document.<br>
You will find an extensive manual describing all **compareGropus** capabilities with real examples in the [vignette](./articles/compareGroups_vignette.html).<br>
Also, **compareGroups** package has been published in Journal of Statistical Software [Subirana et al, 2014] (https://www.jstatsoft.org/v57/i12/).
*********
## Who we are
<img style="float:right; padding:10px" width="25%" src="./man/figures/prbb.jpg" />
**`compareGroups`** is developed and maintained by Isaac Subirana, Hector Sanz, Joan Vila and collaborators at the cardiovascular epidemiology research unit (URLEC), located at [Barcelona Biomedical Research Park (PRBB)](http://www.prbb.org/) .
<br><br><br><br><br>
<img style="float:left; padding:10px" width="20%" src="./man/figures/logo_regicor.jpg" />
As the driving force behind the [REGICOR study](https://www.regicor.org), URLEC has extensive experience in statistical epidemiology, and is a national reference centre for research into cardiovascular diseases and their risk factors.
<br><br>
*********
## Gets started
Install the package from CRAN
```{r, eval=FALSE}
install.packages("compareGroups")
```
or the lattest version from Github
```{r, eval=FALSE}
library(devtools)
devtools::install_github("isubirana/compareGroups")
```
### Building the descriptive table
```{r}
library(compareGroups)
data(regicor)
tab <- descrTable(year ~ . -id , regicor, hide.no = "no",
method=c(triglyc=2, tocv=2, todeath=2), sd.type = 3)
export2md(tab, header.background = "black", header.color = "white",
caption = "Summary by intervention group")
```
### Stratified table
<div class="small">
```{r,size=6}
tabstrat <- strataTable(update(tab, . ~ . -sex), "sex")
export2md(tabstrat, header.background = "black", header.color = "white", size=9)
```
</div>
### Visual exploration
```{r, echo=FALSE, fig.show="hide"}
plot(tab["sex"], "./man/figures/var1", type="png")
plot(tab["age"], "./man/figures/var1", type="png")
```
| | |
|:----------:|:------------:|
| `plot(tab["sex"])` | `plot(tab["age"])` |
| ![](./man/figures/var1sex.png) | ![](./man/figures/var1age.png) |
### Computing Odds Ratios
```{r}
data(SNPs)
tabor <- descrTable(casco ~ .-id, SNPs, show.ratio=TRUE, show.p.overall=FALSE)
export2md(tabor[1:4])
```
### Computing Hazard Ratios
```{r}
library(survival)
regicor$tcv <- Surv(regicor$tocv, regicor$cv=="Yes")
tabhr <- descrTable(tcv ~ .-id-cv-tocv, regicor,
method=c(triglyc=2, tocv=2, todeath=2),
hide.no="no", ref.no="no",
show.ratio=TRUE, show.p.overall=FALSE)
export2md(tabhr[1:10], header.label=c("p.ratio"="p-value"),
caption="Descriptives by cardiovascular event")
```
### Web-based User Interface
For those not familiar to R syntax, a Web User Interface (**WUI**) has been implemented using [Shiny](https://shiny.rstudio.com/) tools, which can be used off line by typing `cGroupsWUI()` after having `compareGroups` package installed and loaded, or remotely just accessing the application hosted in a [shinyapp.io server](https://isubirana.shinyapps.io/compareGroups/).
![ ](./man/figures/WUI.png)