-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_data.Rmd
105 lines (89 loc) · 3.18 KB
/
test_data.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
---
title: "Testing data"
csl: the-american-naturalist.csl
output:
html_document:
theme: cerulean
toc: yes
pdf_document:
toc: yes
<!-- bibliography: references.bib -->
editor_options:
chunk_output_type: console
---
<!--
IMAGES:
Insert them with: ![alt text](image.png)
You can also resize them if needed: convert image.png -resize 50% image.png
If you want to center the image, go through HTML code:
<div style="text-align:center"><img src ="image.png"/></div>
REFERENCES:
For references: Put all the bibTeX references in the file "references.bib"
in the current folder and cite the references as @key or [@key] in the text.
Uncomment the bibliography field in the above header and put a "References"
title wherever you want to display the reference list.
-->
<style type="text/css">
.main-container {
max-width: 1370px;
margin-left: auto;
margin-right: auto;
}
</style>
```{r general_options, include = FALSE}
knitr::knit_hooks$set(
margin = function(before, options, envir) {
if (before) par(mgp = c(1.5, .5, 0), bty = "n", plt = c(.105, .97, .13, .97))
else NULL
},
prompt = function(before, options, envir) {
options(prompt = if (options$engine %in% c("sh", "bash")) "$ " else "> ")
})
knitr::opts_chunk$set(margin = TRUE, prompt = TRUE, comment = "",
collapse = TRUE, cache = FALSE, autodep = TRUE,
dev.args = list(pointsize = 11), fig.height = 3.5,
fig.width = 4.24725, fig.retina = 2, fig.align = "center")
options(width = 137)
```
```{r}
if (! "readr" %in% rownames(installed.packages())) install.packages("readr")
pacs <- readr::read_csv("https://raw.githubusercontent.com/ecomore2/pacs/master/data/pacs.csv",
col_types = paste(c("icfnD", rep("c", 5), rep("D", 4), rep("f", 3)), collapse = ""))
```
```{r}
library(dplyr)
```
## Errors on the dates
Let's explore the time differences between the 4 dates:
```{r}
pacs %>%
filter(abs(onset - hospitalization) > 15 |
abs(onset - consultation) > 15 |
abs(onset - sample_collection) > 15 |
abs(hospitalization - consultation) > 15 |
abs(hospitalization - sample_collection) > 15 |
abs(consultation - sample_collection) > 15) %>%
select(id, onset, hospitalization, consultation, sample_collection)
```
```{r include = FALSE, eval = FALSE}
write.csv("dates_to_check.csv", quote = FALSE, row.names = FALSE)
```
* 1: error on the year
* 4: day and month were switched for onset and consultation
* 6: day and month were switcheid for hospitalization and consultation
* 7: day and month were switched for onset
* 28: day and month were switched for onset
* 33: day and month were switched for onset
* 71: year for consultation and sample_collection are not compatible
* 85: I suspect it should be be December 2012, but should be verified
* 159: probably no error
* 167: day and month were switched for consultation and sample_collection
## Positive cases without any date
```{r}
pacs %>%
filter(is.na(onset), is.na(hospitalization), is.na(consultation), is.na(sample_collection)) %>%
filter(pcr == "positive" | ns1 == "positive") %>%
select(id) %>%
unlist() %>%
unname()
```