-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathb2.qmd
81 lines (64 loc) · 2.64 KB
/
b2.qmd
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
---
title: "Project Title"
author:
- name: First Last
affiliation: Department of ____<br>Vanderbilt University School of Medicine<br>MSCI Biostatistics II
date: last-modified
format:
html:
self-contained: true
number-sections: true
number-depth: 3
anchor-sections: true
smooth-scroll: true
theme: journal
toc: true
toc-depth: 3
toc-title: Contents
toc-location: left
code-link: false
code-tools: true
code-fold: show
code-block-bg: "#f1f3f5"
code-block-border-left: "#31BAE9"
reference-location: margin
fig-cap-location: margin
execute:
warning: false
message: false
major: descriptive statistics; ABD
---
```{r setup}
require(rms) # also loads Hmisc package
getRs('abd.r') # if using getabd function
options(prType='html') # get nicer html output for some functions
```
# Background
To load this complete template into a running `RStudio` script editor window (usually the upper left pane), type the following in the `RStudio` command console (usually the lower left pane).
```{r eval=FALSE}
require(Hmisc) # provides getRs function
getRs('b2.qmd', put='rstudio')
```
# Data Import
If reading a `csv` dataset from ABD use the `getabd` function. If reading a binary R file from `hbiostat.org/data` use the `Hmisc` `getHdata` function instead.[See [this](https://hbiostat.org/rflow/fcreate.html) for methods for importing your own datasets.]{.aside}
```{r import}
# getabd() # run without an argument if you need a list of all
# available ABD datasets
d <- getabd('02-e-2a') # fetch 02-e-2a csv file and store contents in data frame d
# getHdata(support) etc. for larger fully annotated datasets
# d <- support # copy data frame produced by getHdata to use a short name
contents(d) # data dictionary for imported dataset
```
# Descriptive Statistics
Note that the `describe` function considers the `person` variable to be a continuous variable, because it is numeric with lots of levels. So it computes descriptive statistics that are not really appropriate for person ID. To prevent this from happening we could have converted `person` to a character variable using the following code chunk.[In the chunk header we set `eval=FALSE` so the `upData` code is not actually run.]{.aside}
```{r char, eval=FALSE}
d <- upData(d, person = as.character(person))
```
```{r desc}
describe(d)
```
# Computing Environment
The `session` function printed the following. `session` is defined inside an object `markupSpecs` provided by `Hmisc`.
```{r echo=FALSE,results='asis'}
markupSpecs$html$session()
```